https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84949
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu.org
Component|c++ |libstdc++
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
-ffast-math implies -ffinite-math-only which causes GCC to assume no inputs to
isnan/fpclassify are NaN. As a programmer using -ffast-math you give this
guarantee to the compiler, so what you report is a pilot error?
I'm not sure if std::numeric_limits is wrong with -ffinite-math-only given
NaNs are still "supported" as in
double nan = __builtin_nan("");
int main()
{
__builtin_printf ("%f\n", nan);
return __builtin_isnan (nan);
}
> g++-7 t.C -ffast-math -O2
> ./a.out
nan
> echo $?
0
so NaNs are there. But in the testcase I broke the contract with the compiler
with feeding a NaN into isnan().
I guess the compiler could have as well replaced the NaN generated by
__builtin_nan("") with zero.