Boost logo

Boost Users :

Subject: Re: [Boost-users] Is this a known bug in lexical_cast<double> ?
From: Bjorn Reese (breese_at_[hidden])
Date: 2015-07-16 05:18:08

On 07/13/2015 07:26 PM, TILLMAN, MICHAEL D9 wrote:

> Wanted to see if there was a known bug with boost::lexical_cast<double>.
> We're seeing failures on what appear to be valid float strings. When we
> catch the exception, and simply do a second cast on the same string, the
> cast succeeds. The Code fragment:

That sounds very odd.

lexical_cast uses string streams (either from <sstream> or <strstream>
depending on what it detects) so you could try to reproduce the problem
by using those directly.

You may also try to compile with the BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
macro set.

> It fails on the last string, "1.81.....", in the actual program, but
> when compiled into a simple test program, it succeeds.

This often indicates that the exception is just a symptom of another

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at