http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60011
Bug ID: 60011 Summary: Compile error for legal exemplar from c++11 std [class.friend] 11.3.2 Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: peter at hurleysoftware dot com Created attachment 32003 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32003&action=edit testcase g++ 4.8.2 fails to compile the legal example from c++11 std specification, section 11.3.2 [class.friend]: "Declaring a class to be a friend implies that the names of private and protected members from the class granting friendship can be accessed in the base-specifiers and member declarations of the befriended class. [ Example: class A { class B { }; friend class X; }; struct X : A::B { // OK: A::B accessible to friend A::B mx; // OK: A::B accessible to member of friend class Y { A::B my; // OK: A::B accessible to nested member of friend }; }; —end example ]" Note specifically that the private nested class A::B is a valid base specifier for the friend class X. However, g++ 4.8.2 issues the following error diagnostic when A::B is used as the base specifier: peter@thor:~/src/test/c++$ /opt/gcc-4.8.2/bin/g++ -c -std=c++11 nested.cpp nested.cpp:3:8: error: ‘class A::B’ is private class B {}; ^ nested.cpp:7:15: error: within this context struct X : A::B { ^