This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Overload resolution and missing warnings
- To: egcs at cygnus dot com
- Subject: Overload resolution and missing warnings
- From: espie at quatramaran dot ens dot fr (Marc Espie)
- Date: Fri, 20 Mar 1998 19:41:45 +0100
- Reply-To: Marc dot Espie at liafa1 dot liafa dot jussieu dot fr
This is not my code, but I got the following interesting piece recently:
class A
{
public:
void f(long)
{
cout << "A::f(long)" << endl;
}
virtual void f(double)
{
cout << "A::f(double)" << endl;
}
};
class B: public A
{
public:
void f(double)
{
cout << "B::f(double)" << endl;
}
};
int main()
{
B b;
double x;
b.f(x);
long i;
b.f(i);
}
the guy who wrote this was surprised to get B::f(double) called twice.
What is most surprising, however, is that g++ does not even give an
inkling of something amiss. No warning whatsoever, even with
-Wall -Woverloaded-virtual -Weffc++
(okay, some warnings with -Weffc++, but they're related to problems with
iostream :-) )