[Boost-bugs] [Boost C++ Libraries] #6812: boost::lexical_cast<float>(".") returns 0 instead of throwing

Subject: [Boost-bugs] [Boost C++ Libraries] #6812: boost::lexical_cast<float>(".") returns 0 instead of throwing
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-04-20 09:58:22


#6812: boost::lexical_cast<float>(".") returns 0 instead of throwing
--------------------------------------------+-------------------------------
 Reporter: Bruce Merry <bmerry@…> | Owner: apolukhin
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: lexical_cast
  Version: Boost 1.48.0 | Severity: Regression
 Keywords: |
--------------------------------------------+-------------------------------
 The attached program reports
 {{{
 boost::lexical_cast<float>(".") returns 0
 }}}
 when it should report an exception. According to the lexical_cast docs,
 lexical_cast<float>(string) is supposed to be equivalent to
  - using stream extraction, which in turn is defined in terms of
  - num_get on the numeric facet, which is defined in terms of
  - strtold in the C standard, which requires
  - "a non-empty sequence of decimal digits, optionally containing a
 decimal-point character"
 strtold also refers to the grammar for a floating-point literal, which is
 pretty clear that either the part before or the part after the decimal
 point has to be non-empty.

 Compiler is MSVC 2010 SP1. I haven't messed around with locales at all so
 it's whatever the default is for an English install of Windows 7.

 This works with Boost 1.46 under GCC 4.6 - I'm guessing because 1.46 left
 parsing of float strings to operator>>.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6812>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC