Boost logo

Boost :

From: Thomas Matelich (matelich_at_[hidden])
Date: 2005-08-08 13:00:46


Sorry I didn't get to this sooner, but lexical cast has broken my
source code. I have not tracked down the source of the crash because
I currently have a release build, but looking at the diffs, I believe
is it due to whitespace at the end of a string that I am attempting to
convert to a number, this being caused by

151c157,166
< (stream >> std::ws).eof();

---
>                        stream.get() ==
> #if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING)
> // GCC 2.9x lacks std::char_traits<>::eof().
> // We use BOOST_NO_STD_WSTRING to filter out STLport and libstdc++-v3
> // configurations, which do provide std::char_traits<>::eof().
>
>                            EOF;
> #else
>                            std::char_traits<char_type>::eof();
> #endif
You'll note that stream >> std::ws is no longer called.
One note that I must make is that I do not have the vanilla source for
lexical_cast.  From the last time lexical_cast broke my source, I've
commented out stream.unsetf(std::ios::skipws); in the lexical_stream
constructor (see
http://lists.boost.org/MailArchives/boost-users/msg03656.php for the
reason).
I just recalled a unit test we have that would expose the problem (and
it did).  By adding a [stream >> std::ws &&] before the check for eof,
my problem was resolved.  Is there a reason we want to fail with
trailing whitespace?
Thanks,
Tom

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk