
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Gaetano Mendola Sent: Monday, November 26, 2012 12:12 PM To: boost@lists.boost.org 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@hetp.u-net.com