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++/1782: C++ erroneous requirement for final overrider



>Number:         1782
>Category:       c++
>Synopsis:       C++ erroneous requirement for final overrider
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 26 09:36:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Frank Pilhofer
>Release:        2.97 20010122 (experimental)
>Organization:
>Environment:
System: Linux rose 2.2.13 #1 Mon Nov 8 15:08:22 CET 1999 i586 unknown
Architecture: i586
host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: ../configure --prefix=/local/pkg/gcc/20010122 --with-gnu-as=/local/bin/as --with-gnu-ld=/local/bin/ld
>Description:
 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):


             /-- Bi ---\
            /           \
     /---- B ------\     \
    A                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
for Di.

 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

>How-To-Repeat:

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 {};

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:

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