Boost C++ Libraries: Ticket #7157: [lexical_cast] convert volatile int to string cause Run-Time Check Failure #2 https://svn.boost.org/trac10/ticket/7157 <p> The following code produces a Run-Time Check Failure 2 - Stack around the variable 'buf' was corrupted, if compiled with MSVC2008: </p> <pre class="wiki">#include "boost/lexical_cast.hpp" int main() { volatile boost::uint32_t n = 10; std::string str = boost::lexical_cast&lt;std::string&gt;(n); return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7157 Trac 1.4.3 Antony Polukhin Tue, 24 Jul 2012 18:16:54 GMT <link>https://svn.boost.org/trac10/ticket/7157#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7157#comment:1</guid> <description> <p> Could not reproduce it on MSVC2010. Can you attach more info about this bug (backtrace, line number that triggers this error) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 24 Jul 2012 19:21:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7157#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7157#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7157#comment:1" title="Comment 1">apolukhin</a>: </p> <blockquote class="citation"> <p> Could not reproduce it on MSVC2010. Can you attach more info about this bug (backtrace, line number that triggers this error) </p> </blockquote> <p> try it on MSVC2008. If you have this one. </p> <p> compiler didn't find specialization for detail::lcast_src_length so sizeof(buf) is 2 bytes: </p> <pre class="wiki">std::size_t const src_len = lcast_src_length::value; char_type buf[src_len + 1]; // src_len equal 1 here </pre><p> fix: </p> <pre class="wiki">&lt; typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay&lt;Source&gt;::type src; --- &gt; typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay&lt;boost::remove_cv&lt;Source&gt;::type&gt;::type src; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 29 Jul 2012 18:54:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7157#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7157#comment:3</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/79797" title="Fix bug with volatile types (refs #7157)">[79797]</a>) Fix bug with volatile types (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7157" title="#7157: Bugs: [lexical_cast] convert volatile int to string cause Run-Time Check ... (closed: fixed)">#7157</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 05 Aug 2012 09:46:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7157#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7157#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/79871" title="Merge bugfix for volatile types (refs #7157)">[79871]</a>) Merge bugfix for volatile types (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7157" title="#7157: Bugs: [lexical_cast] convert volatile int to string cause Run-Time Check ... (closed: fixed)">#7157</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 05 Aug 2012 09:48:31 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/7157#comment:5 https://svn.boost.org/trac10/ticket/7157#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.51.0</span> </li> </ul> Ticket Antony Polukhin Sun, 05 Aug 2012 18:12:19 GMT <link>https://svn.boost.org/trac10/ticket/7157#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7157#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/79878" title="Added notes for lexical_cast library about fixed #7157 ">[79878]</a>) Added notes for lexical_cast library about fixed <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7157" title="#7157: Bugs: [lexical_cast] convert volatile int to string cause Run-Time Check ... (closed: fixed)">#7157</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Wed, 05 Sep 2012 18:23:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7157#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7157#comment:7</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80409" title="Merge from trunk: 1) #warning replaced with #error (refs #7228) 2) ...">[80409]</a>) Merge from trunk: 1) #warning replaced with #error (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7228" title="#7228: Bugs: Bugs: #warning in lexical_cast.hpp causes MSVC compile error (closed: fixed)">#7228</a>) 2) Pavel Korzh added to thanks list (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7157" title="#7157: Bugs: [lexical_cast] convert volatile int to string cause Run-Time Check ... (closed: fixed)">#7157</a>) 3) BOOST_NOEXCEPT modifiers added where possible 4) better support for c++11 Unicode characters 5) fixed compilation with MSVC+STLPort 6) more agressive usage of Traits template parameter 7) Added lexical_cast(const <a class="missing wiki">CharType</a>* chars, std::size_t count) function overload (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6430" title="#6430: Feature Requests: Optimized code for `boost::iterator_range&lt;std::string::iterator&gt;` (closed: wontfix)">#6430</a> and refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6663" title="#6663: Feature Requests: Avoiding input copying (closed: fixed)">#6663</a>) 8) Fixed GCC warning in numeric_cast_test.cpp 9) Fix compilation of lexical cast with MSVC 2003 (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7255" title="#7255: Bugs: lexical_cast is broken on MSVC .NET 2003 (closed: fixed)">#7255</a>) </p> </description> <category>Ticket</category> </item> </channel> </rss>