This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Ambiguous base class
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Matt Austern <austern at apple dot com>, Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 09 Sep 2002 23:35:30 -0700
- Subject: Re: Ambiguous base class
Again, here is my example:
struct A { int x; };
struct B1 : public A { };
struct B2 : public A { };
struct D : public B1, public B2 { };
int f(D d) {
return d.B1::A::x;
}
I looked at this in the standard recently (in connection with the new
parser) -- but I don't remember what I read.
What I do remember is that you're supposed to look at "B1::A::x" as
two pieces: a nested-name-specifier (B1::A::) and an unqualified name.
You resolve the nested-name-specifier to a class or namespace; in this
case "A". You then look for "x" in "A", and you can use "A" to
disambiguate things, but "B1" is lost to you at this point.
In other words, your case is no different than if you add in:
struct Z { typedef A ZA; };
return d.ZA::x;
Now, I do wish I remembered what lead me to this conclusion...
(FYI, EDG 3.0 rejects your test case as well.)
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com