egcs-980517 bug report

Martin von Loewis martin@mira.isdn.cs.tu-berlin.de
Fri May 22 00:44:00 GMT 1998


> I think the following C++ code should not compile, according to
> section 11.1 of the ISO spec.
> 
> class B {
> protected:
> 	B() { }
> };
> 
> class D : public B { void f(); };
> 
> void D::f() {
> 	B b;			//error
> }

Could you be more specific as to why this is ill-formed? Section 11.1
only specifies that B::B() is a protected member of class B.

11.2 then specifies (in [class.access.base]/1) that this constructor
is still protected in class D. [class.access.base]/4 then specifies
that a member that is protected in a derived class is accessible in
the scope of that derived class.

Therefore, B::B() is accessible within D::f(). I cannot see why the
code above is in error.

Regards,
Martin



More information about the Gcc-bugs mailing list