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]
Other format: [Raw text]

[Bug c++/12946] New: Multiple inheritance (vtbls get messed up)


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


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