c++/9122: qualified name forced to be used in non-public derived class
Neil Booth
neil@daikokuya.co.uk
Fri Jan 3 08:46:00 GMT 2003
ZhenYu Hou wrote:-
> Sorry to bother you.
No problem.
> But I still believe c++/9122 is a bug as the "p" in
> class "C" is not an access to the base of "C", but a newly defined pointer.
> Please see below:
>
> class A {};
> class B : A {
> A* pp; // not full qualified, OK!
> };
> class C : public B {
> public:
> C(A*);// compiler : `class A' is inaccessible
> void f(A*) {} compiler : `class A' is inaccessible
> A* p; // compiler : `class A' is inaccessible
> ::A* p2; // full qualified, OK!
> };
>
> I compiled the code with gcc2.95.3, VC7, BC5.5.1, all passed. And I looked
> up the C++ standard but have not found anything that forbid the sample code
> to compile.
That just shows you that many compilers can be wrong.
> Another point is if "A" in the sample was replace by "::A", all passed, it
> seems strange.
11.2p1 and 11.2p4 imply that A is accessible from B, but not from C.
Hence the results you observe.
Name lookup always gives the base class A in either case according to
3.4.1p7.
Neil.
More information about the Gcc-bugs
mailing list