Boost C++ Libraries: Ticket #12889: Invalid downcast warning in boost::lexical_cast when using UBSAN https://svn.boost.org/trac10/ticket/12889 <p> The attempt to <code>lexical_cast</code> an <code>enum class</code> into a <code>std::string</code> produces a warning with UBSAN. GCC version: </p> <p> g++-6 (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901 </p> <p> CXXFLAGS: -std=c++11 -fsanitize=undefined </p> <p> Warning text for the attached test program: </p> <pre class="wiki">(...)/boost/lexical_cast/detail/converter_lexical_streams.hpp:236:43: runtime error: downcast of address 0x7ffddfb77d38 which does not point to an object of type 'basic_unlockedbuf' 0x7ffddfb77d38: note: object is of type 'std::__cxx11::basic_stringbuf&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;' 69 7f 00 00 e8 ca fb c9 69 7f 00 00 21 dc d8 00 00 00 00 00 21 dc d8 00 00 00 00 00 21 dc d8 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'std::__cxx11::basic_stringbuf&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;' </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12889 Trac 1.4.3 arvo@… Thu, 09 Mar 2017 14:27:56 GMT attachment set https://svn.boost.org/trac10/ticket/12889 https://svn.boost.org/trac10/ticket/12889 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">lexical_cast.cxx</span> </li> </ul> <p> Minimal test program </p> Ticket Antony Polukhin Fri, 10 Mar 2017 04:37:17 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/12889#comment:1 https://svn.boost.org/trac10/ticket/12889#comment:1 <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.63.0</span> </li> </ul> <p> That issue has been fixed <a class="ext-link" href="https://github.com/boostorg/lexical_cast/issues/21"><span class="icon">​</span>here</a> in Boost 1.63 </p> Ticket