[Bug c/28073] Type-punned pointer passed as function parameter generates bad assembly sequence
sorenj at us dot ibm dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 19 16:54:00 GMT 2006
------- Comment #2 from sorenj at us dot ibm dot com 2006-06-19 16:44 -------
Changing just one line of the test program to the (AFAIK) legal C code. By
casting through void *, we are addressing Andrew's concerns about violating the
C rules.
Foo *pFoo = *(Foo **) ((void *)&longPtr); /* // BAD! */
eliminates the type-punned warning, even at the highest possible warning level,
and continues to generate code the results in a bad return value. This test
case illustrates that this problem is actually worse than we originally
thought, as now incorrect code is generated without any warning.
$ gcc -Wstrict-aliasing=2 -Wall -O2 badcase.c
$ ./a.out ; echo $?
76
$ gcc -Wstrict-aliasing=2 -Wall -O2 -fno-strict-aliasing badcase.c
$ ./a.out ; echo $?
1
--
sorenj at us dot ibm dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|DUPLICATE |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28073
More information about the Gcc-bugs
mailing list