http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48981
Summary: bootstrap-lto -O3 produces miscompiled, broken gcc
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
GCC crashes because of violation of strict aliasing rules. The same memory
location is accessed in vec_gc_o_reserve_1 through (struct vec_prefix *)
pointer, then in VEC_tree_base_quick_push through (struct VEC_tree_base *).
Optimization moves the code around in a wrong way.
This patch fixes it:
--- gcc/vec.c
+++ gcc/vec.c
@@ -37,11 +37,11 @@
struct vec_prefix
{
unsigned num;
unsigned alloc;
void *vec[1];
-};
+} __attribute__ ((may_alias));
#ifdef GATHER_STATISTICS
/* Store information about each particular vector. */