This is the mail archive of the gcc-bugs@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]

C++ bug with inheritance



   Hi,

 I have attached a C++ test case that breaks the current 01/22 snapshot
and has been reported to me back to the 2.96 pseudo-release. This bug
happens with a complex inheritance hierarchy (base class leftmost):


    A ---- B -- Bi -----
     \      \           \
      \      \-----\     \
       \             D --- Di
        \- C ------/     /
            \           /
             \- Ci -----


 The classes A, B, C and D each implement a virtual function f(), the
classes Bi, Ci and Di don't.

 For background, this class hierarchy comes from CORBA, where A is an
abstract base class of all skeletons, B, C and D are generated skeleton
classes, where interface D inherits B and C. Bi, Ci and Di are the user
implementations for each interface, using implementation inheritance.

 c++ -v -c test.cc yields

gcc version 2.97 20010122 (experimental)
test.cc:22: sorry, not implemented: `function_decl' not supported by dump_type
test.cc:22: no unique final overrider for `struct Di' in `<type error>'
test.cc:22: candidates are: `virtual void B::f()'
test.cc:22:                 `virtual void C::f()'

 (error repeating three times with the same line number and content).
Line number 22 contains the declaration of class Di.

 I would like this code to compile cleanly. According to ISO 14882
(Ansi C++), §10.2, par. 2 (p. 166), "a member name f in one sub-object
B hides a member name f in a sub-object A if A is a base class sub-
object of B. Any declarations that are so hidden are eliminated from
consideration."

 Therefore, D::f hides both B::f and C::f, and there is no ambiguity.

	Frank



-- 
Frank Pilhofer  ...........................................  fp@fpx.de
When money talks, nobody criticises its accent! - Alfred E. Neuman

struct A {
  virtual void f ();
};

struct B : virtual public A {
  void f ();
};

struct C : virtual public A {
  void f ();
};

struct D : virtual public B, virtual public C {
  void f ();
};

struct Bi : virtual public B {};

struct Ci : virtual public C {};

struct Di : virtual public Bi, virtual public Ci, virtual public D {};


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