private base class doesn't seem to be

Martin von Loewis
Thu Nov 5 15:45:00 GMT 1998

> class Base1 { };
> class Int1 : virtual protected Base1 { };
> class Int2 : private virtual Base1 { };
> class Der : private Int1, public Int2 {
> 	Base1 * f(Der *pDer);
> };
> Base1 *
> Der::f( Der * pDer)
> {
> 	return pDer;
> };
> I think the release is correct and the later snapshot is wrong.

As usual, you don't indicate *why* you think this code should be
rejected. In my reading of the standard, it is well-formed.

Base1 is accessible, if an invented public member in Base1 is
accessible. This invented member is protected in Int2. Therefore, it
is accessible in Der. In addition, the access in f goes through a
pointer to Der. Therefore, Base1 is accessible in Der::f, and pDer can
be implicitly cast to Base1.


More information about the Gcc-bugs mailing list