http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57719
Bug ID: 57719 Summary: wrong code at -O3 on x86_64-linux-gnu Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Current gcc trunk (and gcc-4.8) produces wrong code for the following testcase on x86_64-linux when compiled at -O3 in both 32-bit and 64-bit modes. This is a regression from 4.7.x. $ gcc-trunk -v gcc version 4.9.0 20130625 (experimental) [trunk revision 200388] (GCC) $ gcc-trunk -O2 reduced.c $ a.out 1 $ gcc-4.7 -O3 reduced.c $ a.out 1 $ gcc-4.8 -O3 reduced.c $ a.out 0 $ gcc-trunk -O3 reduced.c $ a.out 0 ----------------------------------------------------------------- int printf (const char *, ...); int u; int a, b, c[2], d, *e, f, g; int fn2 () { int t[1]; int i; i = 0; for (; i < 1; i++) t[i] = 0; for (d = 0; d; d = 1) { int *s[1] = {&t[0]}; g = a = *s[0]; } f = g; return 1; } void fn1 () { for (; b < 2; b++) { int *p = &u; *p = 0; *p = fn2(); e = &c[b]; *e = 0; } } int main () { fn1 (); printf ("%d\n", u); return 0; }