[Bug c++/12946] New: Multiple inheritance (vtbls get messed up)
cxl at ntllib dot org
gcc-bugzilla@gcc.gnu.org
Fri Nov 7 18:29:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12946
Summary: Multiple inheritance (vtbls get messed up)
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cxl at ntllib dot org
CC: gcc-bugs at gcc dot gnu dot org
gcc (GCC) 3.4 20031006 (experimental)
(MingW build)
The following simple example crashes on execution. It seems the compiler mixes
up vtbl entries during multiple inheritance.
#include <stdio.h>
struct A
{
virtual void afn() { puts("A::afn"); }
// A must have vtbl to make this crash
};
struct B
{
virtual void bfn() { puts("B::bfn"); }
};
struct C : A, B
{
virtual void bfn() { puts("C::B::bfn"); }
};
void Bcall(B& b)
{
b.bfn();
}
int main()
{
C c;
puts("calling C::B::bfn crashes...");
Bcall(c);
return 0;
}
More information about the Gcc-bugs
mailing list