public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/38777]  New: gcc optimize flag causes different program behavior
@ 2009-01-09  8:16 dov dot grobgeld at gmail dot com
  2009-01-09 10:34 ` [Bug c/38777] " rguenth at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dov dot grobgeld at gmail dot com @ 2009-01-09  8:16 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/38777] gcc optimize flag causes different program behavior
  2009-01-09  8:16 [Bug c/38777] New: gcc optimize flag causes different program behavior dov dot grobgeld at gmail dot com
@ 2009-01-09 10:34 ` rguenth at gcc dot gnu dot org
  2009-01-09 10:38 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-01-09 10:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-01-09 10:34 -------
Try -fno-strict-aliasing -fno-strict-overflow.  This is likely a program bug.
Hard to say without a testcase though.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38777


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/38777] gcc optimize flag causes different program behavior
  2009-01-09  8:16 [Bug c/38777] New: gcc optimize flag causes different program behavior dov dot grobgeld at gmail dot com
  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
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-01-09 10:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2009-01-09 10:38 -------
Also, if it is floating point using app on i?86, -msse2 -mfpmath=sse or
-ffloat-store.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38777


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/38777] gcc optimize flag causes different program behavior
  2009-01-09  8:16 [Bug c/38777] New: gcc optimize flag causes different program behavior dov dot grobgeld at gmail dot com
  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
  3 siblings, 0 replies; 5+ messages in thread
From: dov dot grobgeld at gmail dot com @ 2009-01-09 10:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dov dot grobgeld at gmail dot com  2009-01-09 10:46 -------
The only flag that had any affect was the -ffloat-store option, which made the
problem disappear.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38777


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/38777] gcc optimize flag causes different program behavior
  2009-01-09  8:16 [Bug c/38777] New: gcc optimize flag causes different program behavior dov dot grobgeld at gmail dot com
                   ` (2 preceding siblings ...)
  2009-01-09 10:46 ` dov dot grobgeld at gmail dot com
@ 2009-01-09 20:41 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-01-09 20:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2009-01-09 20:41 -------
Then this is most likely a dup of bug 323 which will be fixed for 4.5.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
          Component|c                           |middle-end


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38777


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-01-09 20:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-09  8:16 [Bug c/38777] New: gcc optimize flag causes different program behavior dov dot grobgeld at gmail dot com
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

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).