When using a volatile function pointer and compiling with -O2 optimization, the resulting program will not correctly return from the function pointer but will instead jump to another point of the program. I have been able to reproduce this behavior with gcc 3.4.6, 4.0.2 and the x86 locally hosted 4.1.1 version of gcc.
Originally the bug was discovered with: $ powerpc-603-linux-gnu-gcc -v Reading specs from /opt/crosstool/gcc-3.4.5-glibc-2.3.6/powerpc-603-linux-gnu/lib/gcc/powerpc-603-linux-gnu/3.4.5/specs Configured with: /home/mbenedict/src/crosstool-0.43/build/powerpc-603-linux-gnu/gcc-3.4.5-glibc-2.3.6/gcc-3.4.5/configure --target=powerpc-603-linux-gnu --host=i686-host_pc-linux-gnu --prefix=/opt/crosstool/gcc-3.4.5-glibc-2.3.6/powerpc-603-linux-gnu --with-cpu=603 --enable-cxx-flags=-mcpu=603 --with-headers=/opt/crosstool/gcc-3.4.5-glibc-2.3.6/powerpc-603-linux-gnu/powerpc-603-linux-gnu/include --with-local-prefix=/opt/crosstool/gcc-3.4.5-glibc-2.3.6/powerpc-603-linux-gnu/powerpc-603-linux-gnu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c --enable-shared --enable-c99 --enable-long-long Thread model: posix gcc version 3.4.5 I will attach the .i file that reproduces this condition in the first comment (I can't seem to attach from the new bug screen). -- Summary: Optimization corrupts volatile function pointer return handling Product: gcc Version: 3.4.5 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mbenedict at aclaratech dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: powerpc-603-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36226