Bug 45471 - ICE with PCH and differening strict-aliasing settings
Summary: ICE with PCH and differening strict-aliasing settings
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: pch (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-08-31 23:11 UTC by Zdenek Sojka
Modified: 2021-10-12 07:52 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-09-30 23:02:19


Attachments
reduced header file (93 bytes, text/plain)
2010-08-31 23:16 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-08-31 23:11:28 UTC
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
Comment 1 Andrew Pinski 2010-08-31 23:14:42 UTC
The PCH should be rejected for the differences in strict-aliasing.
Comment 2 Zdenek Sojka 2010-08-31 23:16:46 UTC
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.
Comment 3 Andrew Pinski 2010-09-30 23:02:19 UTC
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 {
Comment 4 Zdenek Sojka 2010-12-08 14:37:21 UTC
(In reply to comment #3)

This patch indeed fixes the problem. (verified at r167585, x86_64-linux)
Comment 5 Andrew Pinski 2021-10-12 07:52:42 UTC
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.