This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12946] New: Multiple inheritance (vtbls get messed up)
- From: "cxl at ntllib dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Nov 2003 18:29:19 -0000
- Subject: [Bug c++/12946] New: Multiple inheritance (vtbls get messed up)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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;
}