[Bug c++/26838] Legal program rejection - protected base method addressing fails from grandchild class
Simon80 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Mar 24 07:02:00 GMT 2006
------- 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
More information about the Gcc-bugs
mailing list