This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ bug report
- To: gcc-bugs at gcc dot gnu dot org
- Subject: g++ bug report
- From: Olaf Luethje <luethje at ert dot rwth-aachen dot de>
- Date: Thu, 02 Mar 2000 12:08:44 +0100
- Organization: ISS
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;
}