c++/525: Problem with Multiple Inheritance and -pedantic

Ralf.Hartmann@iwr.uni-heidelberg.de Ralf.Hartmann@iwr.uni-heidelberg.de
Mon Sep 11 08:16:00 GMT 2000


>Number:         525
>Category:       c++
>Synopsis:       Problem with Multiple Inheritance and -pedantic
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 11 08:16:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Ralf.Hartmann@iwr.uni-heidelberg.de
>Release:        gcc2.95.2 and gcc version 2.96 20000911 (experimental)
>Organization:
>Environment:

>Description:

Hi there,
the appended program breaks when compiling with -pedantic, although we
think that it should compile just as fine as when not using that flag.
This problem exists with gcc2.95.2 as well as with the most recent
snapshot 2.96 20000911. The compiler loses the ability to cast from a
derived class to a base class that exists multiply in the inheritance
lattice.
  

Ralf Hartmann


==========================================================
struct Base {
    void clear();
};

struct D1: public Base {};
struct D2: public Base {};

struct Final: public D1, public D2 {
    void run(){ D1::clear(); };
};
=========================================================
Error messages:
bug_test.cc: In method `void Final::run()':
bug_test.cc:9: cannot convert a pointer of type `Final' to a pointer of  type `Base'
bug_test.cc:9: because `Base' is an ambiguous base class

>How-To-Repeat:

>Fix:

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


More information about the Gcc-bugs mailing list