Boost logo

Boost :

Subject: Re: [boost] [math] boost::math::isfinite fails with --fast-math
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2012-11-26 07:29:11


> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Gaetano
> Mendola
> Sent: Monday, November 26, 2012 12:12 PM
> To: boost_at_[hidden]
> Subject: [boost] [math] boost::math::isfinite fails with --fast-math
>
> Hi all,
> I'm wandering if this is to be expected, the following code fails if compiled with --fast-math:
>
> //====================================================
> #include <boost/math/special_functions/fpclassify.hpp>
> int main() {
> const float a = 0.0f/0.0f;
> assert(not boost::math::isfinite(a)); } //====================================================

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 ;-)

But see what the organ grinder has to say...

Paul

---
Paul A. Bristow,
Prizet Farmhouse, Kendal LA8 8AB  UK
+44 1539 561830  07714330204
pbristow_at_[hidden]

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