Opened 4 years ago

Closed 4 years ago

#13536 closed Bugs (wontfix)

boost::lexical_cast<int>(" 1 ") can no longer handle whitespace

Reported by: maxim.egorushkin@… Owned by: Antony Polukhin
Milestone: To Be Determined Component: lexical_cast
Version: Boost 1.61.0 Severity: Showstopper
Keywords: Cc:

Description

boost::lexical_cast can no longer handle whitespace when converting strings to integers:

    #include <string>
    #include <iostream>
    #include <boost/lexical_cast.hpp>

    int main() {
        auto i = boost::lexical_cast<int>(" 1 ");
        std::cout << i << '\n';
    }

The above incorrectly throws an exception.

The correct result of boost::lexical_cast<int>(" 1 ") is 1 and no exception.

At least boost version 1.54 did not have this problem.

Change History (2)

comment:1 by Antony Polukhin, 4 years ago

LexicalCast should not handle that inpit. There's even a test that is at least 13 years old to make sure that lexical cast throws on whitespaces in input.

comment:2 by Antony Polukhin, 4 years ago

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