Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#6452 closed Bugs (fixed)

lexical_cast fails when src inserts 0 chars into stream.

Reported by: Eric Niebler Owned by: Antony Polukhin
Milestone: Boost 1.49.0 Component: lexical_cast
Version: Boost 1.48.0 Severity: Regression
Keywords: Cc:

Description

The following code works with 1.46.1 but fails with a bad_lexical_cast exception on 1.48.

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

struct my_string
{
        friend std::ostream &operator<<(std::ostream& sout, my_string const& st)
        {
                return sout << "";
        }
};

int main()
{
        try
        {
                my_string st;
                std::string st2 = boost::lexical_cast<std::string>(st);
        }
        catch(boost::bad_lexical_cast const &e)
        {
                std::cout << e.what() << std::endl;
        }
}

Change History (3)

comment:1 by Antony Polukhin, 11 years ago

Status: newassigned

comment:2 by Antony Polukhin, 11 years ago

Resolution: fixed
Status: assignedclosed

Duplicates #6264, #6298
Already fixed in trunk, fixes merged to 1.49.0
Tests were updated with your example

comment:3 by Eric Niebler, 11 years ago

Sorry for the dupe! Thanks for the quick response.

Note: See TracTickets for help on using tickets.