http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45770
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID --- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-09-26 19:36:39 UTC --- (In reply to comment #4) > > class A > { > > friend class B; > > public: > A(int i) { a = i; } > > protected: > A(int i, int j) { a = i ^ j; } > > private: > A() { a = 0; } > int a; > > }; > > class B : private A // making protected will allow local variables A below > { > > public: > B(int i) : A () { a = i >> 1; b = i & 1; } B is a friend of A so can call the private constructor. > private: > bool b; > > }; > > class C : public B > { > > public: > C() : B(4) { ::A foo(3); } // functions of B may have local variables ::A > // but not A A(int) is public, so it can be called > }; > > class D : public A > { > friend class D; What is this supposed to do? > > D(int i, int j) : A(i,j) A(int, int) is protected, so D can call it on its base sub-object > { > A d(i,j); // friend class D of class D has no inherited rights here > // note that friends do not have inherited objects in general The object 'd' is not a sub-object of D, so there is no access to that constructor from D's member functions. > } > }; > > main () { A bar(3); } // main may have local variables A That constructor is public, so of course it can. Your example is not valid C++, that's not a problem with GCC.