[Boost-bugs] [Boost C++ Libraries] #5983: Stack overflow with Karma floating point generator

Subject: [Boost-bugs] [Boost C++ Libraries] #5983: Stack overflow with Karma floating point generator
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-10-04 20:31:15


#5983: Stack overflow with Karma floating point generator
---------------------------------------+------------------------------------
 Reporter: matt.chambers42@… | Owner: hkaiser
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: spirit
  Version: Boost Development Trunk | Severity: Problem
 Keywords: karma stack overflow |
---------------------------------------+------------------------------------
 This spirit code causes a stack overflow on MSVC 9 and seg fault on GCC
 4.2.1 with boost 1.43 and trunk.

 {{{
 #include <boost/spirit/include/karma.hpp>
 #include <string>
 using namespace std;

 template <typename T>
 struct double12_policy : boost::spirit::karma::real_policies<T>
 {
     // we want to generate up to 12 fractional digits
     static unsigned int precision(T) { return 12; }
 };

 string to_string(double value)
 {
     using namespace boost::spirit::karma;
     typedef real_generator<double, double12_policy<double> >
 double12_type;
     static const double12_type double12 = double12_type();
     char buffer[256];
     char* p = buffer;
     generate(p, double12, value);
     return string(&buffer[0], p);
 }

 int main()
 {
     cout << to_string(7.0714098800910119e-313);
     return 0;
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5983>
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:07 UTC