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]

no conflicting return type warning w/MI


/***

This test should, I think, warn that base classes A and B have
conflicting return types for pure virtual function foo().

    $ c++ -O2 -W -Wall test.cxx -UWARN_PROPERLY
    $ a.out 
    134514876 2 2
    $ c++ -O2 -W -Wall test.cxx -DWARN_PROPERLY
    test.cxx:41: conflicting return type specified for virtual function `double C::foo()'
    test.cxx:25:   overriding definition as `int A::foo()'
    $ c++ --version
    egcs-2.91.34
    
    
The proper 'conflicting return type' warning is not produced if the
order of multiple inheritance is reversed

***/
#include <iostream.h>

class A {
public:
    virtual int foo() = 0;
};

class B {
public:
    virtual double foo() = 0;
};

class C
#ifdef WARN_PROPERLY
  : public A, public B 
#else
  : public B, public A
#endif
{
public:
    virtual double foo() { return 2; }
};

int
main() {
    C * c = new C;
    B * b = c;
    A * a = c;
    cout << a->foo() << " " << b->foo() << " " << c->foo() << endl;
}


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