[Bug c++/17874] New: Reference to member of protected base should be an error
kerch at cup dot hp dot com
gcc-bugzilla@gcc.gnu.org
Thu Oct 7 00:16:00 GMT 2004
Referencing the member function "l" in the below example should
not be allowed. The friend relationship that "A" has to "C" is
not inherited in "B" (see 11.4 P8).
class A {
public:
void l();
friend class C;
};
class B : protected A {
};
class C {
void v(B * g) { g->l(); }
};
class C {
void v(B * g) {
g->l(); // Error -- referencing member in B,
// or cast to base and reference in A,
// which is the same as the following:
(static_cast<A *>(g))->l(); // Error -- can't cast to protected base
((A *)g)->l(); // Okay -- old-style cast ignores access
A *p;
p->l(); // Okay -- referencing member in A
}
};
--
Summary: Reference to member of protected base should be an error
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kerch at cup dot hp dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17874
More information about the Gcc-bugs
mailing list