From: Jonathan Wakely Date: Mon, 7 Sep 2015 17:17:23 +0000 (+0100) Subject: Relax Debug Mode assertions on operator-> for smart pointers. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=93023f35f7d9a6ccbc6bb121fb5b95171678924b;p=gcc.git Relax Debug Mode assertions on operator-> for smart pointers. * include/bits/shared_ptr_base.h (__shared_ptr::operator->): Change _GLIBCXX_DEBUG_ASSERT to _GLIBCXX_DEBUG_PEDASSERT. * include/bits/unique_ptr.h (unique_ptr::operator->): Likewise. * testsuite/20_util/shared_ptr/observers/get.cc: Test operator-> on empty shared_ptr. From-SVN: r227524 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 91e3c356b20..91d2957437e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,11 @@ 2015-09-07 Jonathan Wakely + * include/bits/shared_ptr_base.h (__shared_ptr::operator->): Change + _GLIBCXX_DEBUG_ASSERT to _GLIBCXX_DEBUG_PEDASSERT. + * include/bits/unique_ptr.h (unique_ptr::operator->): Likewise. + * testsuite/20_util/shared_ptr/observers/get.cc: Test operator-> on + empty shared_ptr. + * include/bits/regex_compiler.h (_BracketMatcher::_M_is_ready): Initialize using NSDMI and set using _GLIBCXX_DEBUG_ONLY. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index f2f577b9115..75f1a0d489b 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -1054,7 +1054,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp* operator->() const noexcept { - _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0); + _GLIBCXX_DEBUG_PEDASSERT(_M_ptr != 0); return _M_ptr; } diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index 8ab55da75d3..bb96951e4ae 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -295,7 +295,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION pointer operator->() const noexcept { - _GLIBCXX_DEBUG_ASSERT(get() != pointer()); + _GLIBCXX_DEBUG_PEDASSERT(get() != pointer()); return get(); } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc index 85fc71dfd39..867f07a679f 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc @@ -63,11 +63,24 @@ test03() VERIFY( &p->i == &a->i ); } +void +test04() +{ + bool test __attribute__((unused)) = true; + +#if !(defined _GLIBCXX_DEBUG && defined _GLIBCXX_DEBUG_PEDANTIC) + std::shared_ptr p; + auto np = p.operator->(); + VERIFY( np == nullptr ); +#endif +} + int main() { test01(); test02(); test03(); + test04(); return 0; }