Relax Debug Mode assertions on operator-> for smart pointers.
authorJonathan Wakely <jwakely@redhat.com>
Mon, 7 Sep 2015 17:17:23 +0000 (18:17 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 7 Sep 2015 17:17:23 +0000 (18:17 +0100)
* 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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/shared_ptr_base.h
libstdc++-v3/include/bits/unique_ptr.h
libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc

index 91e3c356b207e057fa9fa320e37c6e299e073d05..91d2957437e5547236fe7ed1eb4482e6113ebe1f 100644 (file)
@@ -1,5 +1,11 @@
 2015-09-07  Jonathan Wakely  <jwakely@redhat.com>
 
+       * 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.
 
index f2f577b91159d696a02538df612ed3fba4498432..75f1a0d489b4f20161798c046b2509529b8d5d69 100644 (file)
@@ -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;
       }
 
index 8ab55da75d310811363cc1651d3d00bec9a4c9cf..bb96951e4ae9afd5e154af7279d0cc6d9ab5cd12 100644 (file)
@@ -295,7 +295,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       pointer
       operator->() const noexcept
       {
-       _GLIBCXX_DEBUG_ASSERT(get() != pointer());
+       _GLIBCXX_DEBUG_PEDASSERT(get() != pointer());
        return get();
       }
 
index 85fc71dfd39ec8e68c7925ca240d76278d98835c..867f07a679f002d401e3ffe5620dc2f1d32ce9e8 100644 (file)
@@ -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<int> p;
+  auto np = p.operator->();
+  VERIFY( np == nullptr );
+#endif
+}
+
 int 
 main()
 {
   test01();
   test02();
   test03();
+  test04();
   return 0;
 }