http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56402
Bug #: 56402 Summary: Lambda's this pointer are not initialized inside template classes Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: gonzalob...@gmail.com Created attachment 29503 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29503 The first lambda produces a warning. It compiles but the program behaves wrong. The second lambda crashes the compiler. Compiling with: "g++-4.7.2 -std=c++11 -Wall -Wextra" The first lambda produces the following warnign: "warning: missing initializer for member ‘B<D>::foo() [with D = void]::lambda()>::__this’ [-Wmissing-field-initializers]" It recognizes that it has to capture the this pointer, but it does not initialize it. The code compiles and the executable does not print 10 as it should. The second lambda crashes gcc with the following error: "internal compiler error: in get_expr_operands, at tree-ssa-operands.c:1035" This code compiles with clang 3.2 and produces the right output.