Created attachment 22501 [details] reduced testcase $ g++ -std=c++0x testcase.C $ ./a.out pure virtual method called terminate called without an active exception Aborted Tested revisions r167054 - fail r167002 - fail r165699 - OK
related to PR 46526 ?
It is caused by revision 166167: http://gcc.gnu.org/ml/gcc-cvs/2010-11/msg00053.html
(In reply to comment #1) > related to PR 46526 ? Revision 167049 still fails.
This seems to cause FAILs in libstdc++ testsuite with -O0, for example: $ g++ 42819.ii -std=gnu++0x $ ./a.out terminate called after throwing an instance of 'std::system_error' what(): Unknown error 18446744073709551615 Aborted (all failures I encountered are from 30_threads)
Most of the 30_threads tests will abort without -pthread
Thank you, I did my flag reduction wrongly. It seems using of precompiled headers sometimes causes wrong code, but it's unrelated to this PR.
Created attachment 22846 [details] gcc46-pr46626.patch Untested fix. The problem seems to be that the B::B() ctor body, which is constexpr (and g++ generated) has a CLEANUP_STMT in it, and build_data_member_initialization ignores CLEANUP_STMT, which means the setting of vtable pointer to _ZTV1B + 16 is ignored, thus it stays to be _ZTV1A + 16. The attached patch handles CLEANUP_BODY of CLEANUP_STMT by recursing into it.
With the patch applied to r168236: $ cat test.cpp struct X { virtual int& x(int&)=0; virtual ~X() {} }; struct Y { virtual int& y(int&)=0; virtual ~Y() {} }; struct Z: X, Y { int& x(int&); int& y(int&); }; void func() { Z z; } $ g++ -c -std=c++0x test.cpp test.cpp: In function 'void func()': test.cpp:17:7: in constexpr expansion of 'z.Z::Z()' test.cpp:17:7: internal compiler error: in cxx_eval_bare_aggregate, at cp/semantics.c:6352 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. Without the patch, with the same test.cpp: $ g++ -c -std=c++0x test.cpp; echo $? 0 Without the patch, with slightly different test1.cpp: 0 rk@wata:~/tmp/qqq>cat test1.cpp struct X { virtual int& x(int&)=0; // virtual ~X() {} }; struct Y { virtual int& y(int&)=0; // virtual ~Y() {} }; struct Z: X, Y { int& x(int&); int& y(int&); }; void func() { Z z; } 0 rk@wata:~/tmp/qqq>g++ -c -std=c++0x test1.cpp test1.cpp: In function 'void func()': test1.cpp:17:7: in constexpr expansion of 'z.Z::Z()' test1.cpp:17:7: internal compiler error: in cxx_eval_bare_aggregate, at cp/semantics.c:6338 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.
Author: jakub Date: Mon Dec 27 12:54:30 2010 New Revision: 168271 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168271 Log: PR c++/46626 * semantics.c (build_data_member_initialization): For CLEANUP_STMT recurse into CLEANUP_BODY. * g++.dg/cpp0x/constexpr-base4.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/semantics.c trunk/gcc/testsuite/ChangeLog
I see the ICE with the second testcase from #c8 back till r166167, therefore please file it as a separate bugreport, it is not related to this one.