Opened 12 years ago

Closed 11 years ago

#4595 closed Bugs (invalid)

boost::lexical_cast throws std::bad_cast on OS X 10.6 when using _GLIBCXX_DEBUG

Reported by: etlverified@… Owned by: nasonov
Milestone: To Be Determined Component: lexical_cast
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc: antoshkka@…

Description

I'm on Snow Leopard, using the default compiler i686-apple-darwin10-gcc-4.2.1

I compile the following test code with -D_GLIBCXX_DEBUG

unsigned int x = 3;
std::string s = boost::lexical_cast<std::string>(x);

When executed, the program terminates with the output

terminate called after throwing an instance of 'std::bad_cast'
  what():  std::bad_cast
Abort trap

The code runs fine when _GLIBCXX_DEBUG is not defined

Change History (5)

comment:1 by Spinach <dspiciarich@…>, 12 years ago

Have you solved this error? I'm getting a similar error

terminate called after throwing an instance of 'std::bad_cast'
  what():  std::bad_cast
Abort trap

In the error log I see:

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib             	0x00007fff837c33d6 __kill + 10
1   libSystem.B.dylib             	0x00007fff83863972 abort + 83
2   libstdc++.6.dylib             	0x00007fff826785d2 __tcf_0 + 0
3   libstdc++.6.dylib             	0x00007fff82676ae1 __cxxabiv1::__terminate(void (*)()) + 11
4   libstdc++.6.dylib             	0x00007fff82676b16 __cxxabiv1::__unexpected(void (*)()) + 0
5   libstdc++.6.dylib             	0x00007fff82676bfc __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0
6   libstdc++.6.dylib             	0x00007fff8263293f std::__throw_bad_alloc() + 0
7   libboost_regex.dylib          	0x00000001000e94b8 std::collate<char> const& std::use_facet<std::collate<char> >(std::locale const&) + 85 (locale_facets.tcc:117)
8   libboost_regex.dylib          	0x00000001000c1794 boost::re_detail::cpp_regex_traits_base<char>::imbue(std::locale const&) + 124 (cpp_regex_traits.hpp:218)
9   libboost_regex.dylib          	0x00000001000f3e35 boost::re_detail::cpp_regex_traits_base<char>::cpp_regex_traits_base(std::locale const&) + 43 (cpp_regex_traits.hpp:173)
10  libboost_regex.dylib          	0x00000001000f3e83 boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const> boost::re_detail::create_cpp_regex_traits<char>(std::locale const&) + 30 (cpp_regex_traits.hpp:852)
11  libboost_regex.dylib          	0x00000001000f3eed boost::cpp_regex_traits<char>::cpp_regex_traits() + 35 (cpp_regex_traits.hpp:872)
12  libboost_regex.dylib          	0x00000001000f3f33 boost::regex_traits<char, boost::cpp_regex_traits<char> >::regex_traits() + 21 (regex_traits.hpp:75)
13  libboost_regex.dylib          	0x00000001000f3f4b boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > >::regex_traits_wrapper() + 21 (regex_traits.hpp:169)
14  libboost_regex.dylib          	0x00000001000f3f8d boost::re_detail::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::regex_data() + 63 (basic_regex.hpp:212)
15  libboost_regex.dylib          	0x00000001000f4041 boost::re_detail::basic_regex_implementation<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::basic_regex_implementation() + 21 (basic_regex.hpp:248)
16  libboost_regex.dylib          	0x00000001000c1815 boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int) + 75 (basic_regex.hpp:698)

Any help is greatly appreciated, Spinach

comment:2 by Steven Watanabe, 12 years ago

_GLIBCXX_DEBUG breaks ABI compatibility. If you use it, then Boost needs to be built with it too.

comment:3 by anonymous, 11 years ago

I still have this issue and I've built Boost with _GLIBCXX_DEBUG as well.

comment:5 by Antony Polukhin, 11 years ago

Cc: antoshkka@… added
Resolution: invalid
Status: newclosed

Thanks for the link - it explains the problem. It is not a bug of lexical_cast, it is a compiler/library bug.

Note: See TracTickets for help on using tickets.