https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61282
Bug ID: 61282
Summary: vectorisation causes segfaults in a compiled program
during access to an int-casted char[] after bool in a
struct
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: v_pimenov at wargaming dot net
Created attachment 32842
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32842&action=edit
Example source file that produces segfaulting code
When char[] follows a bool in a class, it is 1-byte aligned.
When casted to an int later, gcc 4.7.2 can optimise some operations to use SIMD
instructions that segfault on unaligned access.
In this exact case body of
> for(i=0;i<bound;i++)
> sum ^= p[i];
was optimised to
> pxor (%rdi),%xmm0
which segfaults when
> %rdi % sizeof(void*) != 0
To reproduce compile the attached example source file with
> g++ -fPIC -msse3 -O3 test.cpp
run the executable and observe a SIGSEGV.