Test listed below fails when compiled with -02 optimization at IA64. It appears that instruction scheduler misses dependency between two assignments in the 'set_code' routine and falsely reorders them. $ cat test.c typedef struct s_t { short a; short b; } *ps; void set_code (ps obj, short code) { *((int *) obj) = 0; obj->a = code; } int printf(const char *, ...); int main() { struct s_t obj; set_code(&obj, 123); printf("%s: got %d, expected 123\n", ((obj.a == 123)?"PASS":"FAIL"), obj.a); } $ gcc test.c -O2 $ ./a.out FAIL: got 0, expected 123 Here is the assembly code of function 'set_code' with incorrectly reordered instructions. $ gcc test.c -S -O2 .proc set_code# set_code: .prologue .body st2 [r32] = r33 ; obj->a = code; st4 [r32] = r0 ; *((int *) obj) = 0; br.ret.sptk.many b0 PS: the minimal set of optimizations reproducing the failure is "-O1 -fstrict- aliasing -fschedule-insns".
You are violating C89/C99/C++ aliasing rules so this is undefined.
Reopening to ...
Mark as a dup of bug 21920. *** This bug has been marked as a duplicate of 21920 ***