[cfe-dev] [libcxxabi]: why does not the default unexpected handler call terminate() in libcxxabi?

soaliap soaliap at 126.com
Tue Sep 18 03:28:39 PDT 2012

When I executed testsuites in
libcxx/test/depr/exception.unexpected/set.unexpected directory, it failed to
verify the default unexpected handler.
I saw the code in libcxx/src/exception.cpp:
#if __APPLE__
#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
  // ...
#else  // __has_include(<cxxabi.h>)
  static std::terminate_handler  __terminate_handler;
  static std::unexpected_handler __unexpected_handler; // default value is 0
#endif  // __has_include(<cxxabi.h>)
__unexpected_handler is a static varible, so its default value is 0, then I
plan to use the __cxa_unexpected_handler in libc++abi instead of
__unexpected_handler. But its default value is default_unexpected_handler,
and it indirectly calls abort_message() rather than std::terminate().

I saw the section "D.11.1 Type unexpected_handler" of n3242.pdf, it says:
    "Default behavior: The implementation's default unexpected_handler calls
Now I'm confused about why the default unexpected handler does not call
terminate() in libcxxabi.

I think it's the reason causes the two testsuites failed:

Is it a bug of libc++abi, or I misunderstood it? Who can give me some
advice? Thanks very much!

View this message in context: http://clang-developers.42468.n3.nabble.com/libcxxabi-why-does-not-the-default-unexpected-handler-call-terminate-in-libcxxabi-tp4026744.html
Sent from the Clang Developers mailing list archive at Nabble.com.

More information about the cfe-dev mailing list