I would like to argue that the default behavior should
be -frounding-math, which is safer than the opposite
used currently.

Back in 2003, the following patch by Roger Sayle :
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00104.html
introduced the -frounding-math option, and changed
the default behavior of GCC to optimize "unsafely".

Have a look at the arguments there.  An important argument was
that this patch was supposed to be a first step, and that
"pragma STDC FENV_ACCESS" support would come as a follow up
patch.  We are still waiting for it, or any other mean
to be able to select the safe option from inside the source
code (or automatic detection of calls to fesetround() in a
program to trigger -frounding-math in many relevant cases).
I, for example, had some hope when the "option attributes"
patches went in recently, but it finally did not cover this
question.

If support for such options had indeed been contributed,
things would have been different.  But there is a main
issue now for developers of things like interval arithmetic.
This kind of code needs this option for working correctly,
and since this is typically code which goes in a library,
it means all their users need to care about setting this option
for their own programs (think about an STL-like implementation
with inline functions in headers, and this is what happens
in practice here).

We frequently get bug reports by CGAL users about that, and
this even forced me to try to implement an attempt at run-time
detection of the presence of -fno-rounding-math to ease debuggability.
I'm sure Boost.Interval must has the same issue.
I am tired of waiting for a solution in GCC, and loosing time
with this problem, and I think the real bug here is in GCC.


As far as performance is concerned, I'm not sure what the
regression impact of switching the default would look like.
Programs already using -ffast-math would not be affected anyway.
It might be nice to see the effect on SPEC or other standard benchmarks,
and it might also be nice to check how many programs are forced
to add the -frounding-math for correctness.

Somehow, I also think that this -fno-rounding-math default is
inconsistent with the general policy of defaults in GCC which
is to aim at safety and correctness first.

I would be glad to read your opinions on this.

--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/

Reply via email to