Opened 6 years ago

Closed 6 years ago

#12889 closed Bugs (fixed)

Invalid downcast warning in boost::lexical_cast when using UBSAN

Reported by: arvo@… Owned by: Antony Polukhin
Milestone: Boost 1.63.0 Component: lexical_cast
Version: Boost 1.58.0 Severity: Problem
Keywords: Cc:

Description

The attempt to lexical_cast an enum class into a std::string produces a warning with UBSAN. GCC version:

g++-6 (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901

CXXFLAGS: -std=c++11 -fsanitize=undefined

Warning text for the attached test program:

(...)/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<char, std::char_traits<char>, std::allocator<char> >'
 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<char, std::char_traits<char>, std::allocator<char> >'

Attachments (1)

lexical_cast.cxx (414 bytes ) - added by arvo@… 6 years ago.
Minimal test program

Download all attachments as: .zip

Change History (2)

by arvo@…, 6 years ago

Attachment: lexical_cast.cxx added

Minimal test program

comment:1 by Antony Polukhin, 6 years ago

Milestone: To Be DeterminedBoost 1.63.0
Resolution: fixed
Status: newclosed

That issue has been fixed here in Boost 1.63

Note: See TracTickets for help on using tickets.