http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58143
Bug ID: 58143 Summary: wrong code at -O3 on x86_64-linux-gnu Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The current gcc trunk and gcc 4.8 produce 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 20130812 (experimental) [trunk revision 201658] (GCC) $ gcc-trunk -O2 small.c $ a.out 0 $ gcc-4.7 -O3 small.c $ a.out 0 $ gcc-trunk -O3 small.c $ a.out -1 $ gcc-4.8 -O3 small.c $ a.out -1 $ ------------------------------------------------------ int printf (const char *, ...); int a, b, c, d, e, f, g, h = 1, i; int foo (int p) { return p < 0 && a < -2147483647 - 1 - p ? 0 : 1; } int *bar () { int j; i = h ? 0 : 1 % h; for (j = 0; j < 1; j++) for (d = 0; d; d++) for (e = 1; e;) return 0; return 0; } int baz () { for (; b >= 0; b--) for (c = 1; c >= 0; c--) { int *k = &c; for (;;) { for (f = 0; f < 1; f++) { g = foo (*k); bar (); } if (*k) break; return 0; } } return 0; } int main () { baz (); printf ("%d\n", b); return 0; }