multiple inheritance bug
Martin v. Loewis
martin@mira.isdn.cs.tu-berlin.de
Wed Mar 31 23:54:00 GMT 1999
> delete b; // segmentation fault
I assume you consider this segmentation fault to be a bug in g++. It
is not, this is a bug in your program.
You are invoking delete on an object whose static type differs from
its dynamic type; yet the the class has no virtual destructor. This is
undefined behaviour: it may work (as it does for A*), it may crash, or
it may toast your computer.
To correct this error, change A and B to
struct A {
virtual ~A(){}
};
struct B {
virtual ~B(){}
};
Hope this helps,
Martin
More information about the Gcc-bugs
mailing list