public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dov dot grobgeld at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/38777]  New: gcc optimize flag causes different program behavior
Date: Fri, 09 Jan 2009 08:16:00 -0000	[thread overview]
Message-ID: <bug-38777-17166@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2009-01-09  8:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-09  8:16 dov dot grobgeld at gmail dot com [this message]
2009-01-09 10:34 ` [Bug c/38777] " rguenth at gcc dot gnu dot org
2009-01-09 10:38 ` jakub at gcc dot gnu dot org
2009-01-09 10:46 ` dov dot grobgeld at gmail dot com
2009-01-09 20:41 ` [Bug middle-end/38777] " pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-38777-17166@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).