This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: -ffast-math and gfortran
On Sun, Jun 04, 2006 at 08:41:42PM -0400, Iwan Kawrakow wrote:
>
> To come back to your example:
>
> program h
> complex z
> z = cmplx(1.e-25,1.e-25)
> call div(z,z)
> end program h
> subroutine div(a,b)
> complex a, b, c
> c = a / b
> print *, c
> end subroutine div
>
> gfortran h.f90 && ./a.out
> ( 1.000000 , 0.000000 )
> gfortran -ffast-math h.f90 && ./a.out
> ( NaN, NaN)
> gfortran -fno-math-errno -funsafe-math-optimizations -fno-trapping-math -ffinite-math-only -fno-rounding-math -fno-signaling-nans
> h.f90 && ./a.out
> ( 1.000000 , 0.000000 )
> The last line uses all flags set by -ffast-math except fcx-limited-range.
Yes, it's a simple example that leads one to test individual
flags (if she knows of their existence). With a much more
complex program with numerous data paths -ffast-math may
give one a false sense of security.
I note you avoided the most important question from my previous
email. What potential unsafe transformations does -ffast-math
trigger? -ffast-math isn't documented! Toon was going to
document all of these transformations until he realized the size
of the job.
Go ahead use -ffast-math. I'll continue to recommend that gfortran
users should avoid it.
--
Steve