NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: toolchain/50940: cc -ffast-math fails to disable denormals on amd64

The following reply was made to PR toolchain/50940; it has been noted by GNATS.

From: Andreas Gustafsson <>
To: Joerg Sonnenberger <>
Subject: Re: toolchain/50940: cc -ffast-math fails to disable denormals on
Date: Fri, 18 Mar 2016 11:48:52 +0200

 Last week, Joerg Sonnenberger wrote:
 > >  Do you at least agree that the current NetBSD behavior is incorrect?
 > No. Just because some parts of the code is compiled with -ffast-math, it
 > doesn't mean that other parts should get incorrect behavior. That
 > includes strtod and other parts of the run time library. As such,
 > changing the FP state automatically on program execution is much more
 > harmful.
 That is a good point, and I'm actually inclined to agree.  In addition
 to the potential harm to unsuspecting libraries, there is also the
 fact that the technique of disabling denormals via crtfastmath.o
 doesn't work if -ffast-math is not specified in the link phase, which
 is likely to be the case when the code compiled with -ffast-math is
 itself a library.  For example, the following build recipe reproduces
 the bug even on the non-NetBSD system that gave correct results when
 the compiling and linking were done in a single cc command:
     cc -c -O3 -ffast-math test_denormal.c
     cc test_denormal.o -lm -o test_denormal
 Now, if we do resolve that NetBSD is correct in not disabling
 denormals, then we have a different bug instead, that of gcc
 generating code that yields infinity when taking the square root of a
 denormal.  I guess I should just report that upstream, with the above
 Earlier, you said:
 > The assumption with -ffast-math is that denormals and infinites
 > don't happen at all.
 I still haven't seen any evidence supporting that assertion when it
 comes to denormals.  The -ffast-math option is shorthand for turning
 on multiple options including -ffinite-math-only, which does what you
 say for NaNs and Infs, but it does not mention denormals:
        Allow optimizations for floating-point arithmetic that assume that
        arguments and results are not NaNs or +-Infs.
 Andreas Gustafsson,

Home | Main Index | Thread Index | Old Index