[RndTbl] Problem with g++ optimization

Sean Cody sean at tinfoilhat.ca
Mon Sep 4 15:28:16 CDT 2006


I need more details in order to help you out.
The -O flags can break some code but it is pretty rare.
The GCC man page does a good job explaining the optimizations done  
for each of the -O levels.

This is totally dependent on the errors you are seeing.
Random guess would be turn off loop unrolling as the optimizer might  
not be detected the loop dependancies properly.
I've had this bite me in the past but without details a random guess  
from center field.

On 4-Sep-06, at 1:04 PM, Dan Martin wrote:

> I am modifying an open source C++ program.  I found that my output  
> was not the same as the original, so I spent the last 3 days  
> searching for the errors in my program, then making extensive back- 
> modifications to make my program's output identical to the  
> original.  I finally went back to the original, and made only  
> minimal changes to allow compilation with my makefile.
>
> The errors persisted.  Reasoning that the original was probably  
> compiled with optimization, I tried that and sure enough the  
> differences disappeared (some with -O and the rest disappeared  
> using -O2).
>
> Calculations done mainly with integer math were fine to begin  
> with.  Using -O, linear interpolation involving doubles yielded the  
> same results, and all results including more complex interpolation  
> and double to int conversions were the same using -O2.
>
> I cannot verify my output other than by using the original program.
>
> Which results are correct?  Am I to assume that optimization does  
> something bad? [my program correct, the original compiled with  
> optimizations incorrect].

-- 
Sean




More information about the Roundtable mailing list