https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117805

--- Comment #2 from mjr19 at cam dot ac.uk ---
There will certainly be differences in some cases. If R=2.0 and Z=-0.0i the
answer might be (0.0,0.0) or (0.0,-0.0).

The point is that Fortran does not specify which of these is correct. Both are
reasonable processor-dependent approximations to the mathematically-correct
result. One could argue that (-0.0,-0.0) would also be correct.

Fortran does not guarantee that R*Z with those input values will, even within a
single program, give identical answers every time it is evaluated.

I'd be happy to see gfortran acquire an extra flag for retaining the current
behaviour. But its current behaviour gives reproducibility guarantees which are
not required by the Fortran standard, not found on several other major
compilers, and quite computationally expensive. Any code which relies on them
is not portable Fortran, and will fail on several major standard-compliant
compilers. My argument is that a guarantee which is not required, and is
computationally expensive, should not be enabled at -O3, and probably not -O2
either.

(For more of my thoughts on IEEE and complex, see
https://www.mjr19.org.uk/IT/IEEE_complex.html )

Reply via email to