Using -O2 or greater, when taking the address of an input argument results in the wrong code. For example: int foo (double d) { int *p = (int *) &d; return (*p); } With -O2 results in: foo: movq -8(%rsp), %eax ret With -O1 results in: foo: movsd %xmm0, -8(%rsp) movq -8(%rsp), %eax ret
Created attachment 8982 [details] Test-case. If compiled for x86_64 with -O2 or greater, results in bogus code.
You are violating C aliasing rules, does -fno-strict-aliasing help?
You are violating C aliasing rules.
(In reply to comment #2) The wonders of -Wall... Yes, -fno-strict-aliasing does help.
Reopening to ...
Mark as a dup of bug 21920. *** This bug has been marked as a duplicate of 21920 ***