This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Ambiguous base class


gcc rejects the following snippet:
  struct A { int x; };
  struct B1 : public A { };
  struct B2 : public A { };
  struct D : public B1, public B2 { };

  int f(D d) {
  #ifdef 1
    return d.B1::A::x;
  #else
    return d.B1::x;
  #endif
  }

As the #ifdef suggests, what gcc dislikes is the
B1::A::x part.  It accepts B1::x, but says that
B1::A::x is ambiguous.

It's always possible that I've missed something
in the Standard, but this seems wrong.  As far as
I can tell from my cursory reading of 3.4.3,
B1::A::x ought to be fine: it should look up A
in B1's scope, and x in B1::A's scope.

So, the usual two questions:
(1) Is there text in the standard that says my
reading is wrong?  Is there an argument that gcc's
behavior is right?
(2) If the answer to #1 is 'no': is this a known
bug?

			--Matt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]