Test: class DB { protected: void foo() {}; }; class DC : public DB { public: DC() { [this]() { DB::foo(); // #1 }(); }; }; int main(void) { DC x; } This is potentially a duplicate of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58972 Clang accepts the code. gcc prints lambda-protected.cpp: In lambda function: lambda-protected.cpp:3:14: error: ‘void DB::foo()’ is protected void foo() {}; ^ lambda-protected.cpp:9:33: error: within this context DB::foo(); ^ And changing #1 to this->DB::foo(); does not help.
Definitely a duplicate of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61149 ;)
Most likely caused by the same problem as http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59483
*** Bug 61149 has been marked as a duplicate of this bug. ***
Author: jason Date: Mon Jun 2 20:47:55 2014 New Revision: 211147 URL: http://gcc.gnu.org/viewcvs?rev=211147&root=gcc&view=rev Log: PR c++/59483 PR c++/61148 * search.c (accessible_p): Use current_nonlambda_class_type. * semantics.c (check_accessibility_of_qualified_id): Likewise. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-59483.C trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-61148.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/search.c trunk/gcc/cp/semantics.c
Fixed on trunk.