[Bug c/38777] New: gcc optimize flag causes different program behavior
dov dot grobgeld at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Jan 9 08:16:00 GMT 2009
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
4. make
5. ./lesson40
6. perl -pi~ -e 's/-g/-O2/' Makefile
7. make clean
8. make
9. ./lesson40
Actual results:
The second run of lesson40 yields chaotic motion.
Expected results:
The second run of lesson40 should give identical result to the first run.
--
Summary: gcc optimize flag causes different program behavior
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dov dot grobgeld at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38777
More information about the Gcc-bugs
mailing list