This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimize flag breaks code on many versions of gcc (not all)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]