http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58246
Bug ID: 58246 Summary: wrong code at -O1 and above (affecting 4.6, 4.7, 4.8, and trunk) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The current gcc trunk (as well as gcc 4.6, 4.7, and 4.8) produces wrong code for the following testcase on x86_64-linux when compiled at -O1 and above in both 32-bit and 64-bit modes. $ gcc-trunk -v gcc version 4.9.0 20130826 (experimental) [trunk revision 201986] (GCC) $ gcc-trunk -O0 small.c $ a.out 1 $ gcc-trunk -O1 small.c $ a.out 0 $ gcc-4.8 -O1 small.c $ a.out 0 $ gcc-4.7 -O1 small.c $ a.out 0 $ gcc-4.6 -O1 small.c $ a.out 0 $ ---------------------------------------- int printf (const char *, ...); int a, b; int main () { int t[2] = {1,1}; for (a = 0; a < 2; a++) { b ^= t[a]; t[a] = t[1] = 0; } printf ("%d\n", b); return 0; }