Index: src/exception.cpp =================================================================== --- src/exception.cpp +++ src/exception.cpp @@ -106,6 +106,9 @@ int uncaught_exceptions() _NOEXCEPT { +#ifdef _LIBCPP_NO_EXCEPTIONS + return 0; +#endif #if defined(__APPLE__) || defined(_LIBCPPABI_VERSION) // on Darwin, there is a helper function so __cxa_get_globals is private # if _LIBCPPABI_VERSION > 1101 @@ -183,7 +186,9 @@ exception_ptr::~exception_ptr() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI +# ifndef _LIBCPP_NO_EXCEPTIONS __cxa_decrement_exception_refcount(__ptr_); +# endif #elif defined(__GLIBCXX__) reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); #else @@ -201,7 +206,9 @@ : __ptr_(other.__ptr_) { #if HAVE_DEPENDENT_EH_ABI +# ifndef _LIBCPP_NO_EXCEPTIONS __cxa_increment_exception_refcount(__ptr_); +# endif #elif defined(__GLIBCXX__) new (reinterpret_cast(this)) __exception_ptr::exception_ptr( reinterpret_cast(other)); @@ -221,8 +228,10 @@ #if HAVE_DEPENDENT_EH_ABI if (__ptr_ != other.__ptr_) { +# ifndef _LIBCPP_NO_EXCEPTIONS __cxa_increment_exception_refcount(other.__ptr_); __cxa_decrement_exception_refcount(__ptr_); +# endif __ptr_ = other.__ptr_; } return *this; @@ -272,7 +281,9 @@ // this whole function would be just: // return exception_ptr(__cxa_current_primary_exception()); exception_ptr ptr; +#ifndef _LIBCPP_NO_EXCEPTIONS ptr.__ptr_ = __cxa_current_primary_exception(); +#endif return ptr; #else # if defined(_MSC_VER) && ! defined(__clang__) @@ -291,7 +302,9 @@ void rethrow_exception(exception_ptr p) { #if HAVE_DEPENDENT_EH_ABI +#ifndef _LIBCPP_NO_EXCEPTIONS __cxa_rethrow_primary_exception(p.__ptr_); +#endif // if p.__ptr_ is NULL, above returns so we terminate terminate(); #elif defined(__GLIBCXX__)