# Re: [RFD] -ffinite-math-only.

Brad Lucier lucier@math.purdue.edu
Fri Aug 2 00:20:00 GMT 2002


I'm weighing into this discussion late (I've been moving).

I think one should not have -ffinite-math-only be the default in Fortran
unless -ffast-math is also the default in Fortran.  The optimizations you
want to trigger with this will change the values that one will obtain with
-O0, and will not match the model that programmers used to either IEEE
arithmetic, the *87 in particular, or other programming languages will
expect by default.

I do not find compelling the argument that one can generate infinities, etc.,
only by operations that lead to undefined results in Fortran.  One
should implement languages in a "least surprise" way; the Fortran standard
(at least for Fortran 77) is so loose about arithmetic that, as I've said
before, standards of precision and accuracy are political, rather than
scientific.  I believe that the standard, as written, would allow 1+3=5,
but I don't find this an argument for an *implementation* to allow this.

Overall, I would prefer a more organized approach to the whole question of
modelling IEEE arithmetic, including which exceptions one wants to allow for
the sake of optimization.  For example, I wanted to separate -ffast-math into
-fno-math-errno, -fno-trapping-math, and -funsafe-math-optimizations because
there is a model of arithmetic implemented in many CPUs that allows one to
declare the first two but not the second and, in conjunction with libraries
that allow the user to set the right operational flags, to get excellent
results in terms of accuracy and precision. The -funsafe-math-optimizations 
flag may still be too coarse, but it seems that there needs to be more thought
given about how to break it up.

Brad



More information about the Gcc-patches mailing list