https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64834
Bug ID: 64834 Summary: Captured variable not available in unevaluated context in a lambda with auto argument Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: holger.gr...@ix-n.net Created attachment 34605 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34605&action=edit Repro $ cat t.cpp template <typename F> void e(F f) { f(1); } template <int I> void bar() { int x; e([&] (const int& y) { (void)sizeof(x); }); // ok e([&] (const auto& y) { (void)sizeof(x); }); // error } void baz() { bar<1>(); } $ c++ t.cpp -std=c++1y -c t.cpp: In instantiation of ‘bar()::<lambda(const auto:1&)> [with auto:1 = int; int I = 1]’: t.cpp:4:6: required from ‘void e(F) [with F = bar() [with int I = 1]::<lambda(const auto:1&)>]’ t.cpp:11:47: required from ‘void bar() [with int I = 1]’ t.cpp:15:21: required from here t.cpp:11:41: error: ‘x’ was not declared in this scope e([&] (const auto& y) { (void)sizeof(x); }); // error ^ I don't see why x wouldn't be available in the second lambda. File with