The following code compiles with gcc 4.8 and clang, but not with gcc 4.9: template <typename> void foo_impl() { int data; auto L = [&](){ return data; }; [&](){ L(); }(); } void foo() { foo_impl<int>(); } The error is: test.cpp: In instantiation of 'foo_impl() [with <template-parameter-1-1> = int]::__lambda1': test.cpp:6:12: required from 'struct foo_impl() [with <template-parameter-1-1> = int]::__lambda1' test.cpp:6:19: required from 'void foo_impl() [with <template-parameter-1-1> = int]' test.cpp:11:19: required from here test.cpp:5:14: error: uninitialized const member 'foo_impl() [with <template-parameter-1-1> = int]::__lambda0::__data' auto L = [&](){ return data; }; ^ The error goes away if: - foo_impl is made a nontemplate - the call to the second lambda is inlined - either lambda is made to capture by value instead of reference
Tested with r197663.
Fixed.
*** Bug 56857 has been marked as a duplicate of this bug. ***