Created attachment 25417 [details] A small program using multiple inheritance, segfaults when run. Affected GCC Versions: 4.6.1 20110819 (prerelease) (Arch Linux package) 4.5.3 (Compiled using Arch defaults, --march=core2) Both x64. GCC 4.2 does not seem to be affected. The attached source code, when compiled without any additional flags, segfaults when executed. The segfault occurs within the ostream. I tried to further minimize the code, but all components of this code seem to be required.
Here is a simplier testcase: struct Base { const int text; Base():text(1) {} Base(int aText) : text(aText) {} }; struct SubA : public virtual Base { protected: int x; public: SubA(int aX) : x(aX) {} }; class SubB : public virtual Base {}; struct Diamond : public SubA, public SubB { Diamond(int text) : Base(text), SubA(5), SubB() {} void printText() { if(text != 2) __builtin_abort(); if(x!=5) __builtin_abort(); } }; int main(int, char**) { Diamond x(2); x.printText(); }
Author: jason Date: Thu Oct 13 18:01:51 2011 New Revision: 179934 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179934 Log: PR c++/50618 * init.c (expand_aggr_init_1): Don't zero-initialize virtual bases of a base subobject. Added: trunk/gcc/testsuite/g++.dg/init/vbase1.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/init.c trunk/gcc/testsuite/ChangeLog
Author: jason Date: Thu Oct 13 18:02:10 2011 New Revision: 179935 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179935 Log: PR c++/50618 * init.c (expand_aggr_init_1): Don't zero-initialize virtual bases of a base subobject. Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/init/vbase1.C Modified: branches/gcc-4_6-branch/gcc/cp/ChangeLog branches/gcc-4_6-branch/gcc/cp/init.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Author: jason Date: Thu Oct 13 18:02:27 2011 New Revision: 179936 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179936 Log: PR c++/50618 * init.c (expand_aggr_init_1): Don't zero-initialize virtual bases of a base subobject. Added: branches/gcc-4_5-branch/gcc/testsuite/g++.dg/init/vbase1.C Modified: branches/gcc-4_5-branch/gcc/cp/ChangeLog branches/gcc-4_5-branch/gcc/cp/init.c branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Author: jason Date: Thu Oct 13 18:03:06 2011 New Revision: 179938 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179938 Log: PR c++/50618 * init.c (expand_aggr_init_1): Don't zero-initialize virtual bases of a base subobject. Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/init/vbase1.C Modified: branches/gcc-4_4-branch/gcc/cp/ChangeLog branches/gcc-4_4-branch/gcc/cp/init.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Fixed for 4.4.7.
*** Bug 51331 has been marked as a duplicate of this bug. ***