This code is accepted by clang. struct bug { int a; int *b = [&]{ return &a; }(); }; But GCC (4.7 and trunk) report a compilation error: error: invalid use of non-static data member ‘bug::a’ struct bug { int a; int *b = [&]{ return &a; }(); }; ^ error: from this location struct bug { int a; int *b = [&]{ return &a; }(); }; ^ calling this->a works.
Confirmed.
This got fixed by today's commits. I'm adding the testcase and closing the PR.
Author: paolo Date: Fri Mar 8 22:52:36 2013 New Revision: 196564 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196564 Log: 2013-03-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/56565 * g++.dg/cpp0x/lambda/lambda-nsdmi2.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi2.C Modified: trunk/gcc/testsuite/ChangeLog
Done.