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]

g++ bug report


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;
}

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