http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55972
Bug #: 55972
Summary: cannot access private member from lambda used in NSDMI
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
The following short translation unit shows the issue:
class C
{
void f();
int j = 10;
int i = [this]() { return this->j; }();
};
$ g++ -std=c++11 x.cc
x.cc: In lambda function:
x.cc:4:11: error: ‘int C::j’ is private
x.cc:5:39: error: within this context
Non-static data member initializers (and lambdas used therein) should be able
to access private members of their class.