From 2c2b55f27f92793e8901f0f5cc70ff470236ccb4 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 8 Aug 2012 16:15:16 +0000 Subject: [PATCH] Change size of reference count field in __libcpp_nmstr from 32 bits to 64 bits for 64 bit targets. This is controls the data layout of all exceptions defined in . This aligns the ABI with that of gcc-4.2. llvm-svn: 161496 --- libcxxabi/src/stdexcept.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libcxxabi/src/stdexcept.cpp b/libcxxabi/src/stdexcept.cpp index 4aa962d0a204..5ea92fb5744a 100644 --- a/libcxxabi/src/stdexcept.cpp +++ b/libcxxabi/src/stdexcept.cpp @@ -27,7 +27,7 @@ private: const char* str_; typedef std::size_t unused_t; - typedef std::int32_t count_t; + typedef std::ptrdiff_t count_t; static const std::ptrdiff_t offset = static_cast(2*sizeof(unused_t) + sizeof(count_t)); @@ -65,7 +65,7 @@ __libcpp_nmstr::operator=(const __libcpp_nmstr& s) const char* p = str_; str_ = s.str_; __sync_add_and_fetch(&count(), 1); - if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), -1) < 0) + if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), count_t(-1)) < 0) delete [] (p-offset); return *this; } @@ -73,7 +73,7 @@ __libcpp_nmstr::operator=(const __libcpp_nmstr& s) inline __libcpp_nmstr::~__libcpp_nmstr() { - if (__sync_add_and_fetch(&count(), -1) < 0) + if (__sync_add_and_fetch(&count(), count_t(-1)) < 0) delete [] (str_ - offset); }