| Summary: | lambda function in NSMI fails to capture non-static data member. | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Olivier Goffart <ogoffart> |
| Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | Keywords: | c++-lambda |
| Priority: | P3 | ||
| Version: | 4.7.0 | ||
| Target Milestone: | 4.8.0 | ||
| Host: | Target: | ||
| Build: | Known to work: | ||
| Known to fail: | Last reconfirmed: | 2013-03-07 00:00:00 | |
| Bug Depends on: | |||
| Bug Blocks: | 54367 | ||
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. |
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.