Boost C++ Libraries: Ticket #6812: boost::lexical_cast<float>(".") returns 0 instead of throwing https://svn.boost.org/trac10/ticket/6812 <p> The attached program reports </p> <pre class="wiki">boost::lexical_cast&lt;float&gt;(".") returns 0 </pre><p> when it should report an exception. According to the lexical_cast docs, lexical_cast&lt;float&gt;(string) is supposed to be equivalent to </p> <ul><li>using stream extraction, which in turn is defined in terms of </li><li>num_get on the numeric facet, which is defined in terms of </li><li>strtold in the C standard, which requires </li><li>"a non-empty sequence of decimal digits, optionally containing a decimal-point character" </li></ul><p> 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. </p> <p> This works with Boost 1.46 under GCC 4.6 - I'm guessing because 1.46 left parsing of float strings to operator&gt;&gt;. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6812 Trac 1.4.3 Bruce Merry <bmerry@…> Fri, 20 Apr 2012 09:58:38 GMT attachment set https://svn.boost.org/trac10/ticket/6812 https://svn.boost.org/trac10/ticket/6812 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">lc.cpp</span> </li> </ul> Ticket Bruce Merry <bmerry@…> Fri, 20 Apr 2012 09:58:44 GMT attachment set https://svn.boost.org/trac10/ticket/6812 https://svn.boost.org/trac10/ticket/6812 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">lc.2.cpp</span> </li> </ul> Ticket Bruce Merry <bmerry@…> Fri, 20 Apr 2012 09:59:56 GMT <link>https://svn.boost.org/trac10/ticket/6812#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6812#comment:1</guid> <description> <p> Ack, the attachment went through twice. lc.cpp and lc.2.cpp are the same file. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sat, 21 Apr 2012 10:23:14 GMT</pubDate> <title>status, milestone changed https://svn.boost.org/trac10/ticket/6812#comment:2 https://svn.boost.org/trac10/ticket/6812#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.50.0</span> </li> </ul> Ticket Antony Polukhin Sat, 21 Apr 2012 11:08:05 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6812#comment:3 https://svn.boost.org/trac10/ticket/6812#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78111" title="Fixes #6812 (now converting &#34;.&#34; to float type throws bad_lexical_cast)">[78111]</a>) Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6812" title="#6812: Bugs: boost::lexical_cast&lt;float&gt;(&#34;.&#34;) returns 0 instead of throwing (closed: fixed)">#6812</a> (now converting "." to float type throws bad_lexical_cast) </p> Ticket Antony Polukhin Thu, 26 Apr 2012 17:59:19 GMT <link>https://svn.boost.org/trac10/ticket/6812#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6812#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78211" title="Merge from trunk: * fixed #6812 (now converting &#34;.&#34; to float type ...">[78211]</a>) Merge from trunk: </p> <ul><li>fixed <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6812" title="#6812: Bugs: boost::lexical_cast&lt;float&gt;(&#34;.&#34;) returns 0 instead of throwing (closed: fixed)">#6812</a> (now converting "." to float type throws bad_lexical_cast) </li></ul> </description> <category>Ticket</category> </item> </channel> </rss>