numerical results differ after irrelevant code change

Robert Dewar dewar@adacore.com
Sun May 8 15:14:00 GMT 2011


On 5/8/2011 10:54 AM, Michael D. Berger wrote:
> On a CentOS box with:
>
> # uname -a
> Linux xxxxxx 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5
> 17:53:09 EST 2011 i686 i686 i386 GNU/Linux
>
> # gcc --version
> gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
>
> and using:
>
> Template Numerical Toolkit (TNT).
>
> as well as numerical software I have written, all in C++, I am doing some
> voluminous and complex arithmetic.  On two occasions I have encountered
> situations in which small, irrelevant modifications of the code result in
> small changes in the result.  In a recent example, using type double, a
> result that is theoretically zero, is being approximated, reasonably, by a
> value of -1.16e-16.  When an unused matrix variable member is added to a
> template class not used in that part of the calculations, the result is
> changed to -1.05e-16, also a reasonable result, but different.  When the new
> variable is commented out, the difference disappears.  The problem does not
> in itself compromise the usefulness of the result, but it does compromise
> confidence.
>
> Thanks for any suggestions.

This kind of result is quite expected on an x86 using
the old style (default) floating-point (becauae of
extra precision in intermediate results).



More information about the Gcc mailing list