diff --git a/include/new b/include/new index 94a28495..b0c47923 100644 --- a/include/new +++ b/include/new @@ -27,6 +27,18 @@ public: virtual const char* what() const noexcept; }; +class bad_array_length : public bad_alloc // C++14 +{ +public: + bad_array_length() noexcept; +}; + +class bad_array_new_length : public bad_alloc +{ +public: + bad_array_new_length() noexcept; +}; + struct nothrow_t {}; extern const nothrow_t nothrow; typedef void (*new_handler)(); @@ -81,6 +93,17 @@ public: virtual const char* what() const _NOEXCEPT; }; +#if defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11) +class _LIBCPP_EXCEPTION_ABI bad_array_length + : public bad_alloc +{ +public: + bad_array_length() _NOEXCEPT; + virtual ~bad_array_length() _NOEXCEPT; + virtual const char* what() const _NOEXCEPT; +}; +#endif + _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec struct _LIBCPP_TYPE_VIS nothrow_t {}; diff --git a/src/new.cpp b/src/new.cpp index b23a516f..4a2af8bc 100644 --- a/src/new.cpp +++ b/src/new.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_NEW + #include #include "new" @@ -186,13 +188,27 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT { } +const char* +bad_array_length::what() const _NOEXCEPT +{ + return "bad_array_length"; +} + +bad_array_length::bad_array_length() _NOEXCEPT +{ +} + +bad_array_length::~bad_array_length() _NOEXCEPT +{ +} + const char* bad_array_new_length::what() const _NOEXCEPT { return "bad_array_new_length"; } -#endif +#endif // _LIBCPPABI_VERSION void __throw_bad_alloc()