From 3882d397c4ad38506d1fe21e5ee3d1d9c82091e4 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 24 Aug 2012 22:15:12 +0000 Subject: [PATCH] Wrap throw in _LIBCPP_NO_EXCEPTIONS in debug.cpp. Calls abort if can't throw an exception. Fixes http://llvm.org/bugs/show_bug.cgi?id=13082. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162613 91177308-0d34-0410-b5e6-96231b3b80d8 --- src/debug.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/debug.cpp b/src/debug.cpp index 406b247b..b8af4dde 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -146,7 +146,11 @@ __libcpp_db::__insert_c(void* __c) size_t nc = __next_prime(2*static_cast(__cend_ - __cbeg_) + 1); __c_node** cbeg = (__c_node**)calloc(nc, sizeof(void*)); if (cbeg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif for (__c_node** p = __cbeg_; p != __cend_; ++p) { __c_node* q = *p; @@ -167,7 +171,11 @@ __libcpp_db::__insert_c(void* __c) __c_node* p = __cbeg_[hc]; __c_node* r = __cbeg_[hc] = (__c_node*)malloc(sizeof(__c_node)); if (__cbeg_[hc] == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif r->__c_ = __c; r->__next_ = p; ++__csz_; @@ -402,7 +410,11 @@ __c_node::__add(__i_node* i) nc = 1; __i_node** beg = (__i_node**)malloc(nc * sizeof(__i_node*)); if (beg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif if (nc > 1) memcpy(beg, beg_, nc/2*sizeof(__i_node*)); free(beg_); @@ -424,7 +436,11 @@ __libcpp_db::__insert_iterator(void* __i) size_t nc = __next_prime(2*static_cast(__iend_ - __ibeg_) + 1); __i_node** ibeg = (__i_node**)calloc(nc, sizeof(void*)); if (ibeg == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif for (__i_node** p = __ibeg_; p != __iend_; ++p) { __i_node* q = *p; @@ -445,7 +461,11 @@ __libcpp_db::__insert_iterator(void* __i) __i_node* p = __ibeg_[hi]; __i_node* r = __ibeg_[hi] = (__i_node*)malloc(sizeof(__i_node)); if (r == nullptr) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_alloc(); +#else + abort(); +#endif ::new(r) __i_node(__i, p, nullptr); ++__isz_; return r;