Bug 56565

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    

Description Olivier Goffart 2013-03-07 21:42:07 UTC
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.
Comment 1 Paolo Carlini 2013-03-07 23:18:27 UTC
Confirmed.
Comment 2 Paolo Carlini 2013-03-08 22:35:33 UTC
This got fixed by today's commits. I'm adding the testcase and closing the PR.
Comment 3 paolo@gcc.gnu.org 2013-03-08 22:52:54 UTC
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
Comment 4 Paolo Carlini 2013-03-08 22:55:30 UTC
Done.