no conflicting return type warning w/MI
Hugh W. Holbrook
holbrook@dsg.stanford.edu
Fri Aug 7 23:55:00 GMT 1998
/***
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;
}
More information about the Gcc-bugs
mailing list