[Bug middle-end/79720] floating point result different at compile time / runtime
tkoenig at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Feb 26 18:33:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79720
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|floating point result |floating point result
|depends on optimization |different at compile time /
|level |runtime
--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Ah... constant folding happens with -O:
From the .optimized dump:
a1 = __complex__ (8.3333333289470346016969415359199047088623046875e-11,
2.22222233121084274117421693446605690525075260666199028492e-20);
a2 = __complex__ (8.3333333289470346016969415359199047088623046875e-11,
2.22222233121084274117421693446605690525075260666199028492e-20);
If constant folding is suppressed by hiding the opportunities to do so via
-fno-inline, this happens:
$ gfortran -O recip-orig.f90 && ./a.out
(8.333333329E-11,2.222222331E-20) (8.333333329E-11,2.222222331E-20)
(0.00000000,0.00000000)
$ gfortran -fno-inline -O recip-orig.f90 && ./a.out
(8.333333329E-11,2.222222170E-20) (8.333333329E-11,2.222222331E-20)
(0.00000000,-1.615587134E-27)
$ gfortran recip-orig.f90 && ./a.out
(8.333333329E-11,2.222222170E-20) (8.333333329E-11,2.222222331E-20)
(0.00000000,-1.615587134E-27)
-ffp-contract has no effect:
$ gfortran -fno-inline -ffp-contract=off -O recip-orig.f90 && ./a.out
(8.333333329E-11,2.222222170E-20) (8.333333329E-11,2.222222331E-20)
(0.00000000,-1.615587134E-27)
$ gfortran -ffp-contract=off -O recip-orig.f90 && ./a.out
(8.333333329E-11,2.222222331E-20) (8.333333329E-11,2.222222331E-20)
(0.00000000,0.00000000)
So, the question becomes why the contant folding gets a different
result from the runtime evaluation.
More information about the Gcc-bugs
mailing list