[Bug c/39330] Bad program bahavior with -O2 optimization in plain C
ebotcazou at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sun Mar 1 08:07:00 GMT 2009
------- Comment #4 from ebotcazou at gcc dot gnu dot org 2009-03-01 08:07 -------
> There is a bug in the gcc compiler for the C code that changes the behavior of
> a simple program with -O2 optimizations, but not with -O1 or -O0.
-O2 enables -fstrict-aliasing so the code must be written in ISO C as far as
aliasing is concerned, otherwise the behavior is undefined.
Your code is not written in ISO C:
#define VL(X) (*((uint32*)(X)))
is a direct violation of ISO C. See the -fstrict-aliasing entry in the GCC
manual or the ISO standard.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot gnu dot
| |org
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39330
More information about the Gcc-bugs
mailing list