[Boost-bugs] [Boost C++ Libraries] #4445: boost:math::float_advance( 0.0, 2 ) stack overflows if denormal numbers are set to zero

Subject: [Boost-bugs] [Boost C++ Libraries] #4445: boost:math::float_advance( 0.0, 2 ) stack overflows if denormal numbers are set to zero
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-07-16 09:51:54


#4445: boost:math::float_advance( 0.0, 2 ) stack overflows if denormal numbers are
set to zero
-----------------------------------------------+----------------------------
 Reporter: Emmet Spier <emmet.spier@…> | Owner: dgregor
     Type: Bugs | Status: new
Milestone: Boost 1.44.0 | Component: math
  Version: Boost 1.40.0 | Severity: Showstopper
 Keywords: |
-----------------------------------------------+----------------------------
 If denormal numbers are set to be zero on the processor (register MXCSR
 bit 6 set) then float_distance( 0.0, any number that is not 1 ) will enter
 invoke a function recurse which fails to exit and the program will crash
 with a stack overflow.

 Ultimately given the current code, this is because boost::math::sign(
 denormal number ) == 0 as opposed to the sign of the denormal number.

 However, behaviour of this function with denormal numbers really ought to
 be defined and documented. Possibly a test to see if denormal numbers are
 disabled needs to be done this case handled appropriately.

 Example code, built with optimisations enabled

 #include <boost/math/special_functions/next.hpp>

 #include <ippcore.h>

 int main()
 {
   double thisWillWork = boost::math::float_advance( 0.0, 2 );
   ippSetDenormAreZeros(1); // or set MXCSR bit six directly
   double thisWillStackOverFlow = boost::math::float_advance( 0.0, 2 );

   return 0;
 }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4445>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC