This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/26838] Legal program rejection - protected base method addressing fails from grandchild class



------- Comment #3 from Simon80 at gmail dot com  2006-03-24 07:01 -------
(In reply to comment #2)
> IIRC (there is a bug about this but I cannot find it) pointer to member
> functions are special as you cannot use them to evade accessibility.
> 

I thought of this after I reported the bug, and then I thought of wrapping a
function around the protected one, which apparently can have its address
grabbed just fine:

class A
{
protected:
  void f(){}
};

class B :
  public A
{
int c;
};

class C :
  public B
{
    protected:
      void g(){A::f();};
      void f()
      {
          A::f();  // ok - see
http://gcc.gnu.org/ml/gcc-bugs/1997-10/msg00221.html
          //&A::f; // error here
          &C::g;   // ok
      }
};

int main ()
{
C x;
}


Does the above lend some validity to this bug?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26838


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]