This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimize flag breaks code on many versions of gcc (not all)
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: minus <minus at toneby dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 19 Jun 2006 00:43:26 +0200
- Subject: Re: Optimize flag breaks code on many versions of gcc (not all)
- References: <1150654206.5257.30.camel@cos.hemma>
Hello,
> This 'little' program behaves bad when compiled with -O. It works fine
> when no -O or -O0 is used.
>
> The function is from Graphics Gem I and has been ported from C to C++
> http://www.acm.org/pubs/tog/GraphicsGems/gems.html#gems
> Woo, Andrew, Fast Ray-Box Intersection, p. 395-396, code: p. 736-737
>
> This is how things went when compiling on my Debian unstable (current as
> of 2006-06-18).
> The problem has also been encountererd on redhat rhel (3?) but not
> investigated there.
>
> No flags were used except -On (The program do compile cleanly with
> -Wall -W -pedantic)
>
>
> -O0 -O1 -O2 -O3
> g++-2.95 ok error error error
> g++-3.3 ok error error error
> g++-3.4 ok ok error error
> g++-4.0 ok error error error
> g++-4.1 ok error error error
>
> g++ -v output for each compiler it further down.
>
> Have I done something wrong or is this something for the bugzilla?
it's hard to tell with code of this size; if you can make the testcase
smaller, it would definitely help. However, given that so many versions
of gcc cause this error, I suspect there is something wrong with your
code (possibly invoking some undefined behavior, using uninitialized
variable, sensitivity to rounding errors, or something like that).
Zdenek