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]

C++ inheritance-template bug in egcs-2.93.03



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                  /*



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