The variable is just an argument to an API with a single argument: Bool CommandParser::processTelemetryDbl(string &theValue) And we're pretty sure the string is not the issue, simply because when we cast it twice, it succeeds the second time on the same string. In addition, I compiled with boost 1.58, and the same code succeeded without having to do the additional cast. This is what has lead us to believe that there is some variable in boost 1.51 that gets set to an invalid value at some point, and the exception resets it to a good value, enabling the second attempt on the same string to succeed. We're hoping someone will recognize the flaw and save us the trouble of having to slog through three years of bug logs to find a reference to the bug so management will consider allowing us to upgrade to a current boost version before the millennium comes to a close. Thanks for the query! You wouldn't happen to know of anyone I could contact that works directly with boost on bug fixes would you? Or would be familiar with the boost bug fix history? Thanks again for expressing an interest, Mike -----Original Message----- From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Jeff Flinn Sent: Wednesday, July 15, 2015 5:36 PM To: boost-users@lists.boost.org Subject: EXTERNAL: Re: [Boost-users] Is this a known bug in lexical_cast<double> ? On 7/13/15 1:26 PM, TILLMAN, MICHAEL D9 wrote:
We're using boost 1.51. Management is reluctant to upgrade because the software is for manned space flight and our current boost version has been stable.
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:
try { dVal = boost::lexical_cast<double>(theValue); }
catch(boost::bad_lexical_cast &eX)
{
... more code ...
firstAttemptFailed = true;
}
// If the first cast succeeded, don't bother to attempt it again.
if(firstAttemptFailed == true)
{
// Let the API throw the actual exception if the second attempt also fails.
dVal = boost::lexical_cast<double>(theValue);
}
The string sequence this fails on is:
...
...
"7104",
"0.416666699999999999983",
"0.22222224",
"4.08233160000000000001",
"1.81436960000000000002",
...
It fails on the last string, "1.81.....", in the actual program, but when compiled into a simple test program, it succeeds.
If there is a known bug, we may be able to get a Boost upgrade installed.
I don't know whether there are known bugs in lexical_cast, but I'd be more suspicious of theValue's actual value. What is it's type, lifetime, etc. Jeff _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users