Protected constructor access rules changed?

Rick Campbell rickc@lehman.com
Sat Jan 31 14:38:00 GMT 1998


[ I'm not on this mailing list, so please explicitly include my
  address in replies. ]

I'm trying to figure out whether the attached file demonstrates a bug
in g++ 2.7.2.2 and egcs-1.0.1 release.  In Derived::Derived (), the
base1 line is fine, but the base2 line says it's an access violation.
Older versions of g++ (old enough that they don't handle the --version
argument) accept this code.  

I'm looking at the December 1996 Working Paper (it's the most current
that I have readily accessible).  So far, I've seen these points which
look relevant:

11.0.1:  a member of a class can be protected, that is, its name can
	 be used only by member functions, static data members, and
	 friends of the class in which it is declared.

12.0.2:  declaring a constructor to be protected ensures that only
	 derived classes and friends can create objects using it.

11.5.1:  When a friend of a member function of a derived class
	 references a protected nonstatic member of a base class, an
	 access check applies in addition to those described earlier
	 in this clause.  Except when forming a pointer to a member,
	 the access must be through a pointer to, reference to, or
	 object of the derived class itself (or any class derived from
	 that class).

	Footnote:  This addititional check does not apply to other
		   members, e. g.  static data members or enumerator
		   member constants.

12.0.2 and 11.5.1 seem to be in conflict.  Does anyone know of
anything more definitive on this issue?  I have a lot of code that
expects for friends of derived classes to be able to use protected
base constructors, so I'm really hoping this is just a g++/egcs bug
rather than a change, but a definitive answer either way would be
useful.

			Rick

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.cc
Type: text/x-c++
Size: 507 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/19980131/2eb23b41/attachment.bin>


More information about the Gcc-bugs mailing list