This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9122: qualified name forced to be used in non-public derived class
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: ZhenYu Hou <hou_zhenyu at hotmail dot com>
- Cc: neil at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Date: Fri, 3 Jan 2003 08:46:17 +0000
- Subject: Re: c++/9122: qualified name forced to be used in non-public derived class
- References: <F65tkMfWqszbNbiLxkX0002075b@hotmail.com>
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.