[repeated] Error accessing protected member

Andrey Slepuhin pooh@msu.ru
Sat Oct 25 12:45:00 GMT 1997


Hi,

I didn't get any responce for my previous bug report, so I
repeat it because error remains in 971023 snapshot. Please,
let me know if I'm wrong or if you take control of the situation.

Compiling the following code with egcs-971016 (and egcs-971023):
-----------------------------------------
class A
{
protected:
  void f(){}
};

class B :
  public A
{
int c;
};

class C :
  virtual public B
{
protected:
  void f() { A::f(); }
};

void main ()
{
C x;
}
------------------------------
I get the following error message:
------------------------------
tmp.C: In method `void C::f()':
tmp.C:4: `void A::f()' is protected
tmp.C:17: within this context
-------------------------------
(This code is localized from OmniBroker 2.0b4, so it works
fine with most of C++ compilers and gcc-2.7.2 too)
Removing "virtual" all works fine. Virtuality of A->B inheritance
doesn't affect to compilation result.
I didn't find anything in new C++ draft that can explain such effect,
so it seems like egcs bug.

Andrey Slepuhin,
Moscow State University



More information about the Gcc-bugs mailing list