From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21579 invoked by alias); 9 Jan 2009 08:16:51 -0000 Received: (qmail 21532 invoked by uid 48); 9 Jan 2009 08:16:40 -0000 Date: Fri, 09 Jan 2009 08:16:00 -0000 Subject: [Bug c/38777] New: gcc optimize flag causes different program behavior X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dov dot grobgeld at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-01/txt/msg00938.txt.bz2 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