This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/79720] floating point result different at compile time / runtime
- From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 26 Feb 2017 20:53:41 +0000
- Subject: [Bug middle-end/79720] floating point result different at compile time / runtime
- Auto-submitted: auto-generated
- References: <bug-79720-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79720
--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #3)
> Where is computed 1./a? AFAICT the roundoff errors difference with
> optimization is restricted to this computation.
Yep, you're right... seems that constant of complex
division is off.
So here is a new, much shorter test case:
$ cat r3.f90
program main
complex :: c1, c2, r1, r2
character(len=50) :: inp
c1 = (12e10, -3.2)
inp = '(12e10, -3.2)'
read (unit=inp, fmt=*) c2 ! Hide the assignment from the optimizer
print *,'c1 - c2 = ', c1-c2 ! Should be zero
r1 = 1/c1 ! Compile-time assignment
r2 = 1/c2 ! Run-time assignment
print *,'r1 = ', r1
print *,'r2 = ', r2
print *,'r1 - r2 = ', r1-r2 ! Should be zero, but is not.
end program main
$ gfortran -O r3.f90
$ ./a.out
c1 - c2 = (0.00000000,0.00000000)
r1 = (8.333333155E-12,2.222222180E-22)
r2 = (8.333333155E-12,2.222221927E-22)
r1 - r2 = (0.00000000,2.524354897E-29)