Boost logo

Boost :

Subject: Re: [boost] [math] boost::math::isfinite fails with --fast-math
From: Gaetano Mendola (mendola_at_[hidden])
Date: 2012-11-26 09:13:13


On 11/26/2012 01:29 PM, Paul A. Bristow wrote:
> http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Optimize-Options.html
>
> says
>
> "
> -ffast-math
> Sets -fno-math-errno, -funsafe-math-optimizations,
> -fno-trapping-math,
>
> -ffinite-math-only, <<<<<<<<<<<< so the IEEE pattern for infinity will never be set.
>
> -fno-rounding-math, -fno-signaling-nans and fcx-limited-range.
>
> This option causes the preprocessor macro __FAST_MATH__ to be defined.
>
> "
>
> So I fear that all bets are off as soon as you enable this option.
>
> (and anyway const float a = 0.0f/0.0f; will be optimised away).
>
> And dividing by zero is never a good idea ;-)

That was the fastest way I found to get a nan I would have written:

const float a = std::numeric_limits<float>::quiet_NaN();

obtaining the same effect.

Gaetano


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk