Boost C++ Libraries: Ticket #8267: lexical_cast uses stream buffers incorrectly https://svn.boost.org/trac10/ticket/8267 <p> As noted in <a class="ext-link" href="http://llvm.org/bugs/show_bug.cgi?id=15446"><span class="icon">​</span>http://llvm.org/bugs/show_bug.cgi?id=15446</a> lexical_cast manipulates stringstream's internal buffer in a non-std conforming way causing it to fail on libc++. </p> <p> If it helps any Boost.Regex has a stream buffer class that (probably) does what you want - see parser_buf in boost/regex/v4/cpp_regex_traits.hpp. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8267 Trac 1.4.3 Antony Polukhin Sat, 16 Mar 2013 09:42:24 GMT status changed https://svn.boost.org/trac10/ticket/8267#comment:1 https://svn.boost.org/trac10/ticket/8267#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> parser_buf looks good, I'd like to use it, but I do not want to add dependency to Boost.Regex. Can you move it to boost/utility or boost/detail? I think this class can be used by lots of people (I've saw some projects that make something similar to provide stack allocated buffer) </p> Ticket anonymous Sat, 16 Mar 2013 17:22:57 GMT <link>https://svn.boost.org/trac10/ticket/8267#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8267#comment:2</guid> <description> <p> I'm happy to move to boost/detail, but looking around I see the iostreams lib has the same functionality, just tried this: </p> <pre class="wiki">#include &lt;boost/iostreams/stream_buffer.hpp&gt; #include &lt;boost/iostreams/device/array.hpp&gt; int main() { namespace io = boost::iostreams; const char* buf = "12345.6789"; io::stream_buffer&lt;io::array_source&gt; sb(buf, buf + std::strlen(buf)); std::istream is(&amp;sb); double d; is &gt;&gt; d; std::cout &lt;&lt; d &lt;&lt; std::endl; assert(is.rdbuf()-&gt;in_avail() == 0); return 0; } </pre><p> Is that a better bet? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 24 Mar 2013 15:26:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8267#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8267#comment:3</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83543" title="Reimplement STL string buffer unlocker (refs #8267 and refs #7704)">[83543]</a>) Reimplement STL string buffer unlocker (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8267" title="#8267: Bugs: lexical_cast uses stream buffers incorrectly (closed: fixed)">#8267</a> and refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7704" title="#7704: Bugs: lexical_cast to filesystem::path fails for string::length &gt; 22 (closed: fixed)">#7704</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 24 Mar 2013 15:44:24 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8267#comment:4 https://svn.boost.org/trac10/ticket/8267#comment:4 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> <p> boost/regex/v4/cpp_regex_traits.hpp version does not fit 100%, copy-pasted it, slightly modified and committed it to lexical_cast.hpp. </p> <p> Iostreams library is huge, also did not fit 100%. </p> Ticket John Maddock Mon, 25 Mar 2013 19:15:27 GMT <link>https://svn.boost.org/trac10/ticket/8267#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8267#comment:5</guid> <description> <p> The change is causing quite a few breakages in Multiprecision, quite a few lexical_cast tests are failing too: <a href="http://www.boost.org/development/tests/trunk/developer/conversion.html">http://www.boost.org/development/tests/trunk/developer/conversion.html</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Tue, 26 Mar 2013 07:57:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8267#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8267#comment:6</guid> <description> <p> Working on that... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Wed, 27 Mar 2013 17:00:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8267#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8267#comment:7</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83601" title="Update code that uses string buffers (refs #8267). Treat cast to ...">[83601]</a>) Update code that uses string buffers (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8267" title="#8267: Bugs: lexical_cast uses stream buffers incorrectly (closed: fixed)">#8267</a>). Treat cast to pointer as compile time error (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8334" title="#8334: Bugs: Change runtime assert to compile time (closed: fixed)">#8334</a>). Update documentation </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Thu, 28 Mar 2013 16:03:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8267#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8267#comment:8</guid> <description> <p> Now libc++ fails. Fixing again... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sat, 30 Mar 2013 07:20:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8267#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8267#comment:9</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83642" title="Fix streams and buffers usage (refs #8267 and refs #7704). Now ...">[83642]</a>) Fix streams and buffers usage (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8267" title="#8267: Bugs: lexical_cast uses stream buffers incorrectly (closed: fixed)">#8267</a> and refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7704" title="#7704: Bugs: lexical_cast to filesystem::path fails for string::length &gt; 22 (closed: fixed)">#7704</a>). Now conversions the use STL streams shall work faster </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Mon, 01 Apr 2013 20:40:46 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8267#comment:10 https://svn.boost.org/trac10/ticket/8267#comment:10 <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/83689" title="Merge from trunk: * Fix stream related issues with libc++ and clang ...">[83689]</a>) Merge from trunk: </p> <ul><li>Fix stream related issues with libc++ and clang (fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7704" title="#7704: Bugs: lexical_cast to filesystem::path fails for string::length &gt; 22 (closed: fixed)">#7704</a>, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8267" title="#8267: Bugs: lexical_cast uses stream buffers incorrectly (closed: fixed)">#8267</a>) </li><li>Change runtime assert to compile time when converting to pointer (fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8267" title="#8267: Bugs: lexical_cast uses stream buffers incorrectly (closed: fixed)">#8267</a>) </li></ul> Ticket