http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51331
Bug #: 51331 Summary: bad code generated when explicitly calling auto-generated constructor of virtual base Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: zhezhe...@yandex.ru If a virtual base class has an auto-generated default constructor, explicitly calling it from the derived class' constructor can result in bad code. The following stripped-down example reproduces the issue: #include <iostream> struct A { A(): x(10) {} virtual ~A() {} int x; }; struct B: public virtual A { }; struct C: public virtual A { }; struct D: public B, virtual public C { D(): B(), C() {} // note an explicit call to C() which is auto-generated }; int main() { D* d = new D(); std::cout << d->x << std::endl; // Crashes here with the following message: // *** glibc detected *** ./test: free(): invalid next size (fast) delete d; } This code used to work correctly in gcc 4.1.2 but crashes in gcc 4.6.2 on i386 (both -m32 and -m64).