Subject: [Boost-bugs] [Boost C++ Libraries] #13366: lexical_cast throws std::bad_cast
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-12-26 04:58:16
#13366: lexical_cast throws std::bad_cast
--------------------------------+-----------------------------
Reporter: amitkumar.sachan@⦠| Owner: Antony Polukhin
Type: Bugs | Status: new
Milestone: To Be Determined | Component: lexical_cast
Version: Boost 1.64.0 | Severity: Regression
Keywords: |
--------------------------------+-----------------------------
lexical_cast always throws std::bad_cast exception while converting values
of type std::basic_string<char, ci_char_traits> (where ci_char_traits is
derived from std::char_traits<char>) to double on Linux. It works on
windows though(i.e. throws boost::bad_lexcial_cast exception for bad
values, and returns double for valid values). It also works on Linux with
boost 1.57. I noticed there has been a change in lexical_cast
implementation that causes this issue now. std::bad_cast exception is
thrown here because locale associated with the stream does not has
std::num_get<char, std::istreambuf_iterator<char, ci_char_traits> > >
facet as shown in the stack trace below. It works with std::string
(std::basic_string<char, std::char_traits<char>) > ) because locale has
std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char>>
> facet.
#0 __cxxabiv1::__cxa_throw (obj=0x60b0c0, tinfo=0x60a3f0
<_ZTISt8bad_cast@@GLIBCXX_3.4>,
dest=0x2aaaaab092e0 <std::bad_cast::~bad_cast()>)
at ../../../../gcc-4.8.1/libstdc++-v3/libsupc++/eh_throw.cc:71
#1 0x00002aaaaab5fb62 in std::__throw_bad_cast ()
at ../../../../../gcc-4.8.1/libstdc++-v3/src/c++11/functexcept.cc:56
#2 0x00000000004051bc in std::__check_facet<std::num_get<char,
std::istreambuf_iterator<char, ci_char_traits> > > (__f=0x0) at
/xxxx/xxxx/xxxx/gcc-4.8.1/include/c++/4.8.1/bits/basic_ios.h:49
#3 0x0000000000404b3f in std::basic_istream<char,
ci_char_traits>::_M_extract<double> (this=0x7fffffffe000,
__v=@0x7fffffffe228: 0) at
/xxxx/xxxx/xxxx/gcc-4.8.1/include/c++/4.8.1/bits/istream.tcc:95
#4 0x0000000000404397 in std::basic_istream<char,
ci_char_traits>::operator>> (this=0x7fffffffe000,
__f=@0x7fffffffe228: 0) at
/xxxx/xxxx/xxxx/gcc-4.8.1/include/c++/4.8.1/istream:219
#5 0x0000000000403b84 in boost::detail::lexical_ostream_limited_src<char,
ci_char_traits>::shr_using_base_class<double> (this=0x7fffffffe1a0,
output=@0x7fffffffe228: 0)
at
/xxxx/xxxx/xxxx/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:600
#6 0x0000000000403503 in boost::detail::lexical_ostream_limited_src<char,
ci_char_traits>::float_types_converter_internal<double>
(this=0x7fffffffe1a0, output=@0x7fffffffe228: 0)
at
/xxxx/xxxx/xxxx/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:744
#7 0x0000000000403145 in boost::detail::lexical_ostream_limited_src<char,
ci_char_traits>::operator>> (
this=0x7fffffffe1a0, output=@0x7fffffffe228: 0)
at
/xxxx/xxxx/xxxx/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:770
#8 0x0000000000402cce in boost::detail::lexical_converter_impl<double,
std::basic_string<char, ci_char_traits, std::allocator<char> >
>::try_convert (arg=..., result=@0x7fffffffe228: 0)
at
/xxxx/xxxx/xxxx/include/boost/lexical_cast/detail/converter_lexical.hpp:485
#9 0x0000000000402a32 in
boost::conversion::detail::try_lexical_convert<double,
std::basic_string<char, ci_char_traits, std::allocator<char> > > (arg=...,
result=@0x7fffffffe228: 0)
at
/xxxx/xxxx/xxxx/include/boost/lexical_cast/try_lexical_convert.hpp:196
#10 0x00000000004027be in boost::lexical_cast<double,
std::basic_string<char, ci_char_traits, std::allocator<char> > > (arg=...)
at /xxxx/xxxx/xxxx/include/boost/lexical_cast.hpp:41
#11 0x0000000000401d7f in lexicalcast (mystr=...) at
lexicalcast_test.cpp:14
#12 0x0000000000401f0d in main () at lexicalcast_test.cpp:39
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13366> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-12-26 05:04:22 UTC