g++ bug report

Olaf Luethje luethje@ert.rwth-aachen.de
Thu Mar 2 03:08:00 GMT 2000


Hi!

Here is a bug I found in gcc version 2.95.2 19991024:
I am working on SunOs 5.7.

Compile this little program. When you run the executable
it will crash. The pure virtual function in class B
makes no sense, since it is already implemented in class A.
Though the compiler does not complain at all, but produces
wrong code.

Regards
Olaf Luethje

#include <iostream.h>

class A
{
  public:
  virtual void test();
};

void A::test()
{
  cout << "A::test() called" << endl;
}

class B: public virtual A
{
  public:
  virtual void test() = 0;  
};

class C: public virtual B
{
  public:
  virtual void test();  
  
};

void C::test()
{
  cout << "B::test() called" << endl;
}

int main()
{
  void (B::* f_ptr)() = &B::test;
  C *c = new C;
  B *b = c;
  (b->*f_ptr)();
  delete c;
}


More information about the Gcc-bugs mailing list