http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50067
Bug #: 50067 Summary: Wrong code with -fpredictive-commoning Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: arthur.j.odw...@gmail.com Created attachment 24994 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24994 Output of "ajo-gcc -std=c99 -O -fpredictive-commoning test.c -v" This failure reproduces for me with svn revision 177688 (2011-08-11). I'm on Ubuntu 10.10, x86-64. cat >test.c <<EOF #include <stdio.h> int a[6] = {0, 0, 0, 0, 7, 0}; static int *p = &a[4]; int main (int argc, char* argv[]) { for (int i=0; i < 4; ++i) { a[i+1] = (a[i+2] > i); *p &= ~1; } printf("%d\n", a[4]); } EOF gcc -std=c99 -O test.c ; ./a.out gcc -std=c99 -O -fpredictive-commoning test.c ; ./a.out The first command line above correctly produces "0". The second command line, with -fpredictive-commoning, produces "6". Note that -fpredictive-commoning is enabled as part of -O3. This test case is reduced from the output of Csmith 2.1.0 (git hash 01aa8b04, https://github.com/Quuxplusone/csmith/), using the following command line: csmith --paranoid --no-longlong --pointers --arrays --jumps --no-consts --volatiles --checksum --no-divs --muls --no-bitfields --no-packed-struct -s 278348999