I downloaded a opengl source tutorial from
http://nehe.gamedev.net/data/lessons/linuxsdl/lesson40.tar.gz and compiled it
twice. The first time with the default Makefile as provided in the tarball. The
program then worked as described in the tutorial, a simulation of a string fell
down the ground and came to a standstill. I then edited the Makefile and
replaced -g with -O2 and recompiled. When running the program the string never
settled but instead I got chaotic motion.
It thus appears that there is an optimization bug that causes numeric
instability of this particualar program.
The tests were conducted with the gcc-4.3.2 under Fedora which has the internal version gcc-4.3.2-7.src.rpm.
Steps to Reproduce:
1. wget http://nehe.gamedev.net/data/lessons/linuxsdl/lesson40.tar.gz
2. tar -xf lesson40.tar.gz
3. cd lesson40_linux_sdl
6. perl -pi~ -e 's/-g/-O2/' Makefile
7. make clean
The second run of lesson40 yields chaotic motion.
The second run of lesson40 should give identical result to the first run.
Try -fno-strict-aliasing -fno-strict-overflow. This is likely a program bug.
Hard to say without a testcase though.
Also, if it is floating point using app on i?86, -msse2 -mfpmath=sse or -ffloat-store.
The only flag that had any affect was the -ffloat-store option, which made the problem disappear.
Then this is most likely a dup of bug 323 which will be fixed for 4.5.
As mentioned this is a dup of bug 323.
*** This bug has been marked as a duplicate of bug 323 ***