Skip to content

[Karma] Real generator broken in 1.76 #688

Description

@chambm
#include <iostream>
#include <string>
#include <limits>
#include <algorithm>
#include <boost/spirit/include/karma.hpp>

int main()
{
    std::cout << BOOST_VERSION << std::endl;
    
    double values[] = { 0.9999, 1.9999, 2.9999, 3.9999, 4.9999, 5.9999, 6.9999, 7.9999, 8.9999, 9.9, 9.9999, 10.99, 10.9999, 11.999, 11.9999 };};
    for (auto value : values)
    {
        std::string s;
        std::back_insert_iterator<std::string> sink(s);
        boost::spirit::karma::generate(sink, boost::spirit::karma::real_generator<>(), value);
        std::cout << s << std::endl;
    }
}

At Coliru as of 6/3/2021, it incorrectly generates:

107600
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
9.9
1.0
10.99
1.0
11.999
1.0

At rextester it correctly generates:

106501
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
9.9
10.0
10.99
11.0
11.999
12.0

I'm not sure when it broke, and it's not broken for every input value, but for fairly mundane values it's very wrong. It seems to have something to do with the number of decimals places.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions