[RndTbl] Problem with g++ optimization
Dan Martin
ummar143 at cc.umanitoba.ca
Mon Sep 4 15:04:08 CDT 2006
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].
--
-Dan
Dr. Dan Martin, MD, CCFP, BSc, BCSc (Hon)
GP Hospital Practitioner
Computer Science grad student
ummar143 at cc.umanitoba.ca
More information about the Roundtable
mailing list