[Bug c/39330] Bad program bahavior with -O2 optimization in plain C
--- 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
[Bug c/39330] Bad program bahavior with -O2 optimization in plain C
--- Comment #1 from adeymo at dc dot uba dot ar 2009-03-01 05:05 --- Created an attachment (id=17379) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17379action=view) Testcase with debug information and explanation Compile with: gcc -save-temps -O2 -Wall -Werror xqsort.c -o xqsort -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39330
[Bug c/39330] Bad program bahavior with -O2 optimization in plain C
--- Comment #2 from adeymo at dc dot uba dot ar 2009-03-01 05:06 --- Created an attachment (id=17380) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17380action=view) Testcase smaller and simpler -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39330
[Bug c/39330] Bad program bahavior with -O2 optimization in plain C
--- Comment #3 from adeymo at dc dot uba dot ar 2009-03-01 05:08 --- (From update of attachment 17380) Compile with: gcc -save-temps -O2 -Wall -Werror xqsort-small.c -o xqsort-small Run with: ./xqsort-small echo ok If compiled with -O1 , the echo command must be executed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39330