Opened 7 years ago

Closed 3 years ago

#11608 closed Bugs (fixed)

boost::spirit::double_ fails with large numbers

Reported by: Tobias Reh <treh@…> Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.59.0 Severity: Regression
Keywords: Cc:

Description

Since 1.59.0, spirit fails to parse large doubles when they are written out.

#include <boost/spirit/include/qi_real.hpp>
#include <iostream>

int main()
{
  // 2^100, exactly representable as double
  auto str = "1267650600228229401496703205376"; 

  double f;

  boost::spirit::qi::parse(str, str + strlen(str), boost::spirit::double_, f);

  // The following code line prints
  //  1.26765e+30 (with boost 1.58.0, correct)
  // -9.25596e+61 (with boost 1.59.0)
  std::cout << f << std::endl;

  return 0;
}

Change History (6)

comment:1 by Tobias Reh <treh@…>, 7 years ago

Component: Nonespirit
Owner: set to Joel de Guzman

comment:2 by Tobias Reh <treh@…>, 7 years ago

Summary: boost::spirit::double_ yields wrong resultboost::spirit::double_ yields fails with large numbers

Actually the line

boost::spirit::qi::parse(str, str + strlen(str), boost::spirit::double_, f);

returns false with boost 1.59.0. So it does not "yield a wrong result" but fails, and I have updated the summary accordingly.

It is still a regression.

comment:3 by Tobias Reh <treh@…>, 7 years ago

Summary: boost::spirit::double_ yields fails with large numbersboost::spirit::double_ fails with large numbers

comment:4 by Joel de Guzman, 7 years ago

I'll have a look over the weekend. Thanks for the report.

comment:6 by Joel de Guzman, 3 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.