This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26838] Legal program rejection - protected base method addressing fails from grandchild class
- From: "Simon80 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Mar 2006 07:01:49 -0000
- Subject: [Bug c++/26838] Legal program rejection - protected base method addressing fails from grandchild class
- References: <bug-26838-12399@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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