mclow.lists created this revision. mclow.lists added reviewers: EricWF, hiraditya, kparzysz. mclow.lists added a subscriber: cfe-commits.
This is a follow on to D21232, which marked a bunch of exception-throwing helper routines as `noreturn`. Now, make them really never return. Either they throw, or they call `abort`. https://reviews.llvm.org/D23855 Files: include/__locale include/any include/array include/bitset include/complex include/deque include/experimental/any include/experimental/dynarray include/experimental/optional include/future include/locale include/memory include/regex include/string include/vector src/locale.cpp src/new.cpp src/string.cpp src/system_error.cpp src/thread.cpp src/typeinfo.cpp
Index: src/typeinfo.cpp =================================================================== --- src/typeinfo.cpp +++ src/typeinfo.cpp @@ -54,12 +54,16 @@ { #ifndef _LIBCPP_NO_EXCEPTIONS throw std::bad_typeid(); +#else + _VSTD::abort(); #endif } void __cxxabiv1::__cxa_bad_cast() { #ifndef _LIBCPP_NO_EXCEPTIONS throw std::bad_cast(); +#else + _VSTD::abort(); #endif } #endif Index: src/thread.cpp =================================================================== --- src/thread.cpp +++ src/thread.cpp @@ -56,6 +56,9 @@ #ifndef _LIBCPP_NO_EXCEPTIONS if (ec) throw system_error(error_code(ec, system_category()), "thread::join failed"); +#else + if (ec) + _VSTD::abort(); #endif // _LIBCPP_NO_EXCEPTIONS } @@ -72,6 +75,9 @@ #ifndef _LIBCPP_NO_EXCEPTIONS if (ec) throw system_error(error_code(ec, system_category()), "thread::detach failed"); +#else + if (ec) + _VSTD::abort(); #endif // _LIBCPP_NO_EXCEPTIONS } Index: src/system_error.cpp =================================================================== --- src/system_error.cpp +++ src/system_error.cpp @@ -258,6 +258,7 @@ #else (void)ev; (void)what_arg; + _VSTD::abort(); #endif } Index: src/string.cpp =================================================================== --- src/string.cpp +++ src/string.cpp @@ -40,7 +40,7 @@ throw T( msg ); #else fprintf(stderr, "%s\n", msg.c_str()); - abort(); + _VSTD::abort(); #endif } Index: src/new.cpp =================================================================== --- src/new.cpp +++ src/new.cpp @@ -241,6 +241,8 @@ { #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + _VSTD::abort(); #endif } Index: src/locale.cpp =================================================================== --- src/locale.cpp +++ src/locale.cpp @@ -107,8 +107,18 @@ return static_cast<size_t>(end - begin); } +_LIBCPP_NORETURN static void __throw_runtime_error(const string &msg) +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw runtime_error(msg); +#else + (void)msg; + _VSTD::abort(); +#endif } +} + #if defined(_AIX) // Set priority to INT_MIN + 256 + 150 # pragma priority ( -2147483242 ) @@ -646,22 +656,18 @@ : collate<char>(refs), __l(newlocale(LC_ALL_MASK, n, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("collate_byname<char>::collate_byname" + __throw_runtime_error("collate_byname<char>::collate_byname" " failed to construct for " + string(n)); -#endif // _LIBCPP_NO_EXCEPTIONS } collate_byname<char>::collate_byname(const string& name, size_t refs) : collate<char>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("collate_byname<char>::collate_byname" + __throw_runtime_error("collate_byname<char>::collate_byname" " failed to construct for " + name); -#endif // _LIBCPP_NO_EXCEPTIONS } collate_byname<char>::~collate_byname() @@ -698,22 +704,18 @@ : collate<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, n, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" + __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" " failed to construct for " + string(n)); -#endif // _LIBCPP_NO_EXCEPTIONS } collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) : collate<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" + __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" " failed to construct for " + name); -#endif // _LIBCPP_NO_EXCEPTIONS } collate_byname<wchar_t>::~collate_byname() @@ -1172,22 +1174,18 @@ : ctype<char>(0, false, refs), __l(newlocale(LC_ALL_MASK, name, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("ctype_byname<char>::ctype_byname" + __throw_runtime_error("ctype_byname<char>::ctype_byname" " failed to construct for " + string(name)); -#endif // _LIBCPP_NO_EXCEPTIONS } ctype_byname<char>::ctype_byname(const string& name, size_t refs) : ctype<char>(0, false, refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("ctype_byname<char>::ctype_byname" + __throw_runtime_error("ctype_byname<char>::ctype_byname" " failed to construct for " + name); -#endif // _LIBCPP_NO_EXCEPTIONS } ctype_byname<char>::~ctype_byname() @@ -1229,22 +1227,18 @@ : ctype<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("ctype_byname<wchar_t>::ctype_byname" + __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname" " failed to construct for " + string(name)); -#endif // _LIBCPP_NO_EXCEPTIONS } ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) : ctype<wchar_t>(refs), __l(newlocale(LC_ALL_MASK, name.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("ctype_byname<wchar_t>::ctype_byname" + __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname" " failed to construct for " + name); -#endif // _LIBCPP_NO_EXCEPTIONS } ctype_byname<wchar_t>::~ctype_byname() @@ -1504,11 +1498,9 @@ : locale::facet(refs), __l(newlocale(LC_ALL_MASK, nm, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__l == 0) - throw runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" + __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS } codecvt<wchar_t, char, mbstate_t>::~codecvt() @@ -4257,11 +4249,10 @@ if (strcmp(nm, "C") != 0) { __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("numpunct_byname<char>::numpunct_byname" + __throw_runtime_error("numpunct_byname<char>::numpunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->decimal_point) __decimal_point_ = *lc->decimal_point; @@ -4296,11 +4287,10 @@ if (strcmp(nm, "C") != 0) { __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("numpunct_byname<char>::numpunct_byname" + __throw_runtime_error("numpunct_byname<char>::numpunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->decimal_point) __decimal_point_ = *lc->decimal_point; @@ -4703,21 +4693,17 @@ __time_get::__time_get(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) - throw runtime_error("time_get_byname" + __throw_runtime_error("time_get_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS } __time_get::__time_get(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) - throw runtime_error("time_get_byname" + __throw_runtime_error("time_get_byname" " failed to construct for " + nm); -#endif // _LIBCPP_NO_EXCEPTIONS } __time_get::~__time_get() @@ -5363,21 +5349,17 @@ __time_put::__time_put(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) - throw runtime_error("time_put_byname" + __throw_runtime_error("time_put_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS } __time_put::__time_put(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__loc_ == 0) - throw runtime_error("time_put_byname" + __throw_runtime_error("time_put_byname" " failed to construct for " + nm); -#endif // _LIBCPP_NO_EXCEPTIONS } __time_put::~__time_put() @@ -5792,11 +5774,10 @@ { typedef moneypunct<char, false> base; __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("moneypunct_byname" + __throw_runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = *lc->mon_decimal_point; @@ -5836,11 +5817,10 @@ { typedef moneypunct<char, true> base; __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("moneypunct_byname" + __throw_runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = *lc->mon_decimal_point; @@ -5897,11 +5877,9 @@ { typedef moneypunct<wchar_t, false> base; __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("moneypunct_byname" + __throw_runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point); @@ -5964,11 +5942,10 @@ { typedef moneypunct<wchar_t, true> base; __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); -#ifndef _LIBCPP_NO_EXCEPTIONS if (loc == nullptr) - throw runtime_error("moneypunct_byname" + __throw_runtime_error("moneypunct_byname" " failed to construct for " + string(nm)); -#endif // _LIBCPP_NO_EXCEPTIONS + lconv* lc = __libcpp_localeconv_l(loc.get()); if (*lc->mon_decimal_point) __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point); @@ -6050,6 +6027,7 @@ throw runtime_error(msg); #else (void)msg; + _VSTD::abort(); #endif } Index: include/vector =================================================================== --- include/vector +++ include/vector @@ -301,7 +301,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw length_error("vector"); #else - assert(!"vector length_error"); + _VSTD::abort(); #endif } @@ -312,7 +312,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw out_of_range("vector"); #else - assert(!"vector out_of_range"); + _VSTD::abort(); #endif } Index: include/string =================================================================== --- include/string +++ include/string @@ -477,11 +477,7 @@ #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS #include <cstdint> #endif -#if defined(_LIBCPP_NO_EXCEPTIONS) -#include <cassert> -#endif - #include <__undef_min_max> #include <__debug> @@ -567,7 +563,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw length_error("basic_string"); #else - assert(!"basic_string length_error"); + _VSTD::abort(); #endif } @@ -578,7 +574,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw out_of_range("basic_string"); #else - assert(!"basic_string out_of_range"); + _VSTD::abort(); #endif } Index: include/regex =================================================================== --- include/regex +++ include/regex @@ -764,7 +764,6 @@ #include <memory> #include <vector> #include <deque> -#include <cassert> #include <__undef_min_max> @@ -965,7 +964,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw regex_error(_Ev); #else - assert(!"regex_error"); + _VSTD::abort(); #endif } Index: include/memory =================================================================== --- include/memory +++ include/memory @@ -637,9 +637,6 @@ #include <tuple> #include <stdexcept> #include <cstring> -#if defined(_LIBCPP_NO_EXCEPTIONS) - #include <cassert> -#endif #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) # include <atomic> @@ -5446,7 +5443,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_weak_ptr(); #else - assert(!"bad_weak_ptr"); + _VSTD::abort(); #endif } Index: include/locale =================================================================== --- include/locale +++ include/locale @@ -3704,6 +3704,8 @@ #ifndef _LIBCPP_NO_EXCEPTIONS if (__wide_err_string_.empty()) throw range_error("wstring_convert: from_bytes error"); +#else + _VSTD::abort(); #endif // _LIBCPP_NO_EXCEPTIONS return __wide_err_string_; } @@ -3793,6 +3795,8 @@ #ifndef _LIBCPP_NO_EXCEPTIONS if (__byte_err_string_.empty()) throw range_error("wstring_convert: to_bytes error"); +#else + _VSTD::abort(); #endif // _LIBCPP_NO_EXCEPTIONS return __byte_err_string_; } Index: include/future =================================================================== --- include/future +++ include/future @@ -518,7 +518,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw future_error(make_error_code(_Ev)); #else - assert(!"future_error"); + _VSTD::abort(); #endif } Index: include/experimental/optional =================================================================== --- include/experimental/optional +++ include/experimental/optional @@ -513,15 +513,21 @@ _LIBCPP_INLINE_VISIBILITY constexpr explicit operator bool() const noexcept {return this->__engaged_;} + _LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY + constexpr void __throw_bad_optional_access() const + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_optional_access(); +#else + _VSTD::abort(); +#endif + } + _LIBCPP_INLINE_VISIBILITY constexpr value_type const& value() const { if (!this->__engaged_) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw bad_optional_access(); -#else - assert(!"bad optional access"); -#endif + __throw_bad_optional_access(); return this->__val_; } @@ -529,11 +535,7 @@ value_type& value() { if (!this->__engaged_) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw bad_optional_access(); -#else - assert(!"bad optional access"); -#endif + __throw_bad_optional_access(); return this->__val_; } Index: include/experimental/dynarray =================================================================== --- include/experimental/dynarray +++ include/experimental/dynarray @@ -106,10 +106,6 @@ #include <__undef___deallocate> -#if defined(_LIBCPP_NO_EXCEPTIONS) - #include <cassert> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -146,7 +142,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_array_length(); #else - assert(!"dynarray::allocation"); + _VSTD::abort(); #endif } return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count)); @@ -287,7 +283,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw out_of_range("dynarray::at"); #else - assert(!"dynarray::at out_of_range"); + _VSTD::abort(); #endif } return data()[__n]; @@ -303,7 +299,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw out_of_range("dynarray::at"); #else - assert(!"dynarray::at out_of_range"); + _VSTD::abort(); #endif } return data()[__n]; Index: include/experimental/any =================================================================== --- include/experimental/any +++ include/experimental/any @@ -82,7 +82,6 @@ #include <typeinfo> #include <type_traits> #include <cstdlib> -#include <cassert> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -104,7 +103,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_any_cast(); #else - assert(!"bad_any_cast"); + _VSTD::abort(); #endif } Index: include/deque =================================================================== --- include/deque +++ include/deque @@ -905,6 +905,8 @@ { #ifndef _LIBCPP_NO_EXCEPTIONS throw length_error("deque"); +#else + _VSTD::abort(); #endif } @@ -914,6 +916,8 @@ { #ifndef _LIBCPP_NO_EXCEPTIONS throw out_of_range("deque"); +#else + _VSTD::abort(); #endif } Index: include/complex =================================================================== --- include/complex +++ include/complex @@ -245,9 +245,6 @@ #include <stdexcept> #include <cmath> #include <sstream> -#if defined(_LIBCPP_NO_EXCEPTIONS) - #include <cassert> -#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header Index: include/bitset =================================================================== --- include/bitset +++ include/bitset @@ -125,9 +125,6 @@ #include <stdexcept> #include <iosfwd> #include <__functional_base> -#if defined(_LIBCPP_NO_EXCEPTIONS) - #include <cassert> -#endif #include <__undef_min_max> @@ -214,8 +211,19 @@ _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong(true_type, false_type) const; unsigned long long to_ullong(true_type, true_type) const; + + _LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY inline + void __throw_overflow_error(const char * __msg) const + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw overflow_error(__msg); +#else + _VSTD::abort(); +#endif + } }; + template <size_t _N_words, size_t _Size> inline _LIBCPP_CONSTEXPR @@ -326,11 +334,8 @@ const_iterator __e = __make_iter(_Size); const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true); if (__i != __e) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw overflow_error("bitset to_ulong overflow error"); -#else - assert(!"bitset to_ulong overflow error"); -#endif + __throw_overflow_error("bitset to_ulong overflow error"); + return __first_[0]; } @@ -349,11 +354,8 @@ const_iterator __e = __make_iter(_Size); const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true); if (__i != __e) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw overflow_error("bitset to_ullong overflow error"); -#else - assert(!"bitset to_ullong overflow error"); -#endif + __throw_overflow_error("bitset to_ullong overflow error"); + return to_ullong(true_type()); } @@ -748,6 +750,26 @@ private: + _LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY inline + void __throw_out_of_range(const char * __msg) const + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range(__msg); +#else + _VSTD::abort(); +#endif + } + + _LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY inline + void __throw_invalid_argument(const char * __msg) const + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw invalid_argument(__msg); +#else + _VSTD::abort(); +#endif + } + _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return base::__hash_code();} @@ -763,11 +785,8 @@ size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str)); for (size_t __i = 0; __i < __rlen; ++__i) if (__str[__i] != __zero && __str[__i] != __one) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw invalid_argument("bitset string ctor has invalid argument"); -#else - assert(!"bitset string ctor has invalid argument"); -#endif + __throw_invalid_argument("bitset string ctor has invalid argument"); + size_t _Mp = _VSTD::min(__rlen, _Size); size_t __i = 0; for (; __i < _Mp; ++__i) @@ -789,19 +808,13 @@ _CharT __zero, _CharT __one) { if (__pos > __str.size()) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw out_of_range("bitset string pos out of range"); -#else - assert(!"bitset string pos out of range"); -#endif + __throw_out_of_range("bitset string pos out of range"); + size_t __rlen = _VSTD::min(__n, __str.size() - __pos); for (size_t __i = __pos; __i < __pos + __rlen; ++__i) if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one)) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw invalid_argument("bitset string ctor has invalid argument"); -#else - assert(!"bitset string ctor has invalid argument"); -#endif + __throw_invalid_argument("bitset string ctor has invalid argument"); + size_t _Mp = _VSTD::min(__rlen, _Size); size_t __i = 0; for (; __i < _Mp; ++__i) @@ -876,11 +889,8 @@ bitset<_Size>::set(size_t __pos, bool __val) { if (__pos >= _Size) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw out_of_range("bitset set argument out of range"); -#else - assert(!"bitset set argument out of range"); -#endif + __throw_out_of_range("bitset set argument out of range"); + (*this)[__pos] = __val; return *this; } @@ -899,11 +909,8 @@ bitset<_Size>::reset(size_t __pos) { if (__pos >= _Size) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw out_of_range("bitset reset argument out of range"); -#else - assert(!"bitset reset argument out of range"); -#endif + __throw_out_of_range("bitset reset argument out of range"); + (*this)[__pos] = false; return *this; } @@ -932,11 +939,8 @@ bitset<_Size>::flip(size_t __pos) { if (__pos >= _Size) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw out_of_range("bitset flip argument out of range"); -#else - assert(!"bitset flip argument out of range"); -#endif + __throw_out_of_range("bitset flip argument out of range"); + reference r = base::__make_ref(__pos); r = ~r; return *this; @@ -1027,11 +1031,8 @@ bitset<_Size>::test(size_t __pos) const { if (__pos >= _Size) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw out_of_range("bitset test argument out of range"); -#else - assert(!"bitset test argument out of range"); -#endif + __throw_out_of_range("bitset test argument out of range"); + return (*this)[__pos]; } Index: include/array =================================================================== --- include/array +++ include/array @@ -108,9 +108,6 @@ #include <iterator> #include <algorithm> #include <stdexcept> -#if defined(_LIBCPP_NO_EXCEPTIONS) - #include <cassert> -#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -212,7 +209,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw out_of_range("array::at"); #else - assert(!"array::at out_of_range"); + _VSTD::abort(); #endif return __elems_[__n]; } @@ -226,7 +223,7 @@ #ifndef _LIBCPP_NO_EXCEPTIONS throw out_of_range("array::at"); #else - assert(!"array::at out_of_range"); + _VSTD::abort(); #endif return __elems_[__n]; } Index: include/any =================================================================== --- include/any +++ include/any @@ -85,7 +85,6 @@ #include <typeinfo> #include <type_traits> #include <cstdlib> -#include <cassert> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header Index: include/__locale =================================================================== --- include/__locale +++ include/__locale @@ -47,6 +47,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); + class _LIBCPP_TYPE_VIS locale; template <class _Facet> @@ -165,10 +167,9 @@ locale locale::combine(const locale& __other) const { -#ifndef _LIBCPP_NO_EXCEPTIONS if (!_VSTD::has_facet<_Facet>(__other)) - throw runtime_error("locale::combine: locale missing facet"); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_runtime_error("locale::combine: locale missing facet"); + return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other))); } @@ -1184,8 +1185,6 @@ _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) -_LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); - template <size_t _Np> struct __narrow_to_utf8 {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits