This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
C++ inheritance-template bug in egcs-2.93.03
- To: egcs-bugs at cygnus dot com
- Subject: C++ inheritance-template bug in egcs-2.93.03
- From: Oskar Enoksson <osken393 at student dot liu dot se>
- Date: Tue, 23 Feb 1999 20:51:19 +0100 (MET)
The following bug caused me some confusion at first. The program is
compiled without warnings, but the wrong virtual function is called.
The trouble seems to be the combination of a static member template
function and a virtual member function with the same name.
The version is egcs-2.93.03 and my platform is alphaev56-dec-osf4.0d
///// Error example test1.cpp
#include <iostream>
class A {
public:
void bar() { foo(); }
virtual void foo() { cout<<"A::foo()"<<endl; }
template<class C> static void foo(C m)
{ cout<<"template A::foo(C)"<<endl; }
};
class B: public A {
public:
virtual void foo() { cout<<"B::foo()"<<endl; }
};
int main(int argc, char **argv) {
B b;
b.bar();
}
> c++ -Wall -o test1 test1.cpp
> ./test1
A::foo()
>
Regards
/Oskar
*/ Oskar Enoksson, Linkoping, Sweden /*