https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63474
Bug ID: 63474 Summary: Optimizer bug causes crash on unaligned integer writes Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: jaf at meyersound dot com Created attachment 33660 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33660&action=edit trivial example program to reproduce the fault I think this is an optimizer bug, since Intel machines should be able to perform non-word-aligned integer writes without crashing. Also, the crash only occurs if optimization is enabled. To reproduce: 1) On an Intel machine, compile and run the attached trivial example program using gcc 4.7.2, like this: root@debian7:/home/jaf/cs6/software# gcc --version gcc (Debian 4.7.2-5) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. root@debian7:/home/jaf/cs6/software# gcc -O3 ./bug_in_gcc_4.7.2.c root@debian7:/home/jaf/cs6/software# ./a.out Testing for g++ unaligned-word-writes optimizer bug... (sizeof(int)==4) Begin unaligned writes to 8 words... Segmentation fault Note the segmentation fault above, which is unexpected. Compiling with -O2 optimization or lower gives the expected (non-crashing) behavior: root@debian7:/home/jaf/cs6/software# gcc -O2 ./bug_in_gcc_4.7.2.c root@debian7:/home/jaf/cs6/software# ./a.out Testing for g++ unaligned-word-writes optimizer bug... (sizeof(int)==4) Begin unaligned writes to 8 words... End unaligned writes. Resulting buffer is: 4a 4a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a 4a