This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
no conflicting return type warning w/MI
- To: egcs-bugs at cygnus dot com
- Subject: no conflicting return type warning w/MI
- From: "Hugh W. Holbrook" <holbrook at dsg dot stanford dot edu>
- Date: Fri, 7 Aug 1998 23:53:01 -0700
- Reply-to: holbrook at dsg dot stanford dot edu
/***
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;
}