Command line: $ g++ -O2 testcase.h $ g++ -O2 testcase.C -fno-strict-aliasing Compiler output: $ g++ -O2 testcase.h $ g++ -O2 testcase.C -fno-strict-aliasing testcase.h: In constructor 'A<<anonymous> >::A() [with int <anonymous> = 0]': testcase.h:17:12: instantiated from here testcase.h:13:5: internal compiler error: in typeid_ok_p, at cp/rtti.c:311 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. Tested revisions: r163636 - crash r153685 - crash 4.4 r149995 - crash
The PCH should be rejected for the differences in strict-aliasing.
Created attachment 21629 [details] reduced header file #include <typeinfo> can be replaced with: namespace std { struct type_info { }; } The second part of testcase is just: ----- testcase.C ----- #include "pr45471.h" ---------------------- $ g++ -O2 pr45471.h $ g++ -O2 pr45471.C -fno-strict-aliasing pr45471.h: In constructor 'A<<anonymous> >::A() [with int <anonymous> = 0]': pr45471.h:12:13: instantiated from here pr45471.h:8:5: internal compiler error: in typeid_ok_p, at cp/rtti.c:311 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.
305 /* Make sure abi::__type_info_pseudo has the same alias set 306 as std::type_info. */ Simple fix: Index: c-pch.c =================================================================== --- c-pch.c (revision 164815) +++ c-pch.c (working copy) @@ -47,6 +47,7 @@ static const struct c_pch_matching const char *flag_name; } pch_matching[] = { { &flag_exceptions, "-fexceptions" }, + { &flag_strict_aliasing, "-fstrict-aliasing" }, }; enum {
(In reply to comment #3) This patch indeed fixes the problem. (verified at r167585, x86_64-linux)
Fixed a different way than my patch. It was fixed by r6-5494 where get_alias_set no longer depends on strict-aliasing. This was done to fix the attribute option fno-strict-aliasing (or fstrict-aliasing) case for functions.