https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87559
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Any gcc bugs seem to be fixed in current trunk. As a single testcase: extern "C" int puts(const char*); constexpr char top_doc[] = ""; void f1() { constexpr auto& doc = top_doc; [](int) { puts(doc); }(1); // should compile [](auto) { puts(doc); }(2); // should compile } void f2() { constexpr char doc[] = ""; [](int) { puts(doc); }(3); // should fail [](auto) { puts(doc); }(4); // should fail } GCC 7 gets three of the four cases wrong, incorrectly rejecting the second, and incorrectly accepting the third and fourth: 87559.cc: In lambda function: 87559.cc:8:19: error: 'doc' is not captured [](auto) { puts(doc); }(2); // should compile ^~~ 87559.cc:8:4: note: the lambda has no capture-default [](auto) { puts(doc); }(2); // should compile ^ 87559.cc:6:19: note: 'constexpr const char (& doc)[1]' declared here constexpr auto& doc = top_doc; ^~~ But GCC 8 gets them all right, compiling the first two and rejecting the last two: 87559.cc: In lambda function: 87559.cc:13:18: error: 'doc' is not captured [](int) { puts(doc); }(3); // should fail ^~~ 87559.cc:13:4: note: the lambda has no capture-default [](int) { puts(doc); }(3); // should fail ^ 87559.cc:12:18: note: 'constexpr const char doc [1]' declared here constexpr char doc[] = ""; ^~~ 87559.cc: In instantiation of 'f2()::<lambda(auto:2)> [with auto:2 = int]': 87559.cc:14:28: required from here 87559.cc:14:19: error: 'doc' is not captured [](auto) { puts(doc); }(4); // should fail ^~~ 87559.cc:14:4: note: the lambda has no capture-default [](auto) { puts(doc); }(4); // should fail ^ 87559.cc:12:18: note: 'constexpr const char doc [1]' declared here constexpr char doc[] = ""; ^~~