http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57347
Bug ID: 57347 Summary: wrong code for bitfield on x86_64-linux at -Os and above Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: dhazeghi at yahoo dot com The following code is miscompiled on x86_64-linux with gcc trunk and 4.8 at -Os and above optimization level. It works correctly with gcc 4.7 (outputs 1). $ gcc-trunk -v gcc version 4.9.0 20130520 (experimental) [trunk revision 199099] (GCC) $ gcc-trunk -O1 wrong.c $ ./a.out 1 $ gcc-4.7 -Os wrong.c $ ./a.out 1 $ gcc-trunk -Os wrong.c $ ./a.out 0 $ ----------------- int printf(const char *, ...); struct S1 { int f0; int f1 : 10; int f2 : 13; }; int i; int *j = &i; static void foo(struct S1 s) { int *p; int l[88]; int **pp = &p; *pp = &l[1]; l[0] = 1; *j = 1 && s.f2; } int main(void) { struct S1 s = { 0, 0, 1 }; foo(s); printf("%d\n", i); return 0; }