Add assertions to extract(const_iterator) functions
authorJonathan Wakely <jwakely@redhat.com>
Mon, 26 Sep 2016 10:17:48 +0000 (11:17 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 26 Sep 2016 10:17:48 +0000 (11:17 +0100)
* include/bits/stl_map.h (map::extract(const_iterator)): Assert that
iterator is not past-the-end.
* include/bits/stl_multimap.h (multimap::extract(const_iterator)):
Likewise.
* include/bits/stl_multiset.h (multiset::extract(const_iterator)):
Likewise.
* include/bits/stl_set.h (set::extract(const_iterator)): Likewise.
* include/bits/unordered_map.h (unordered_map::extract(const_iterator))
(unordered_multimap::extract(const_iterator)): Likewise.
* include/bits/unordered_set.h (unordered_set::extract(const_iterator))
(unordered_multiset::extract(const_iterator)): Likewise.

From-SVN: r240487

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_map.h
libstdc++-v3/include/bits/stl_multimap.h
libstdc++-v3/include/bits/stl_multiset.h
libstdc++-v3/include/bits/stl_set.h
libstdc++-v3/include/bits/unordered_map.h
libstdc++-v3/include/bits/unordered_set.h

index e3e26d1440c092cfac6f5c4633377c154dcee81b..04ec1f1c6f4934af605147387aa8689466efe3b1 100644 (file)
@@ -1,3 +1,17 @@
+2016-09-26  Jonathan Wakely  <jwakely@redhat.com>
+
+       * include/bits/stl_map.h (map::extract(const_iterator)): Assert that
+       iterator is not past-the-end.
+       * include/bits/stl_multimap.h (multimap::extract(const_iterator)):
+       Likewise.
+       * include/bits/stl_multiset.h (multiset::extract(const_iterator)):
+       Likewise.
+       * include/bits/stl_set.h (set::extract(const_iterator)): Likewise.
+       * include/bits/unordered_map.h (unordered_map::extract(const_iterator))
+       (unordered_multimap::extract(const_iterator)): Likewise.
+       * include/bits/unordered_set.h (unordered_set::extract(const_iterator))
+       (unordered_multiset::extract(const_iterator)): Likewise.
+
 2016-09-26  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        PR libstdc++/77717
index f9482e29579682f168a0004d1c58c971fcc57b23..9a0454aa58336930d25a7f205917f473befa88be 100644 (file)
@@ -605,7 +605,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_t.extract(__pos); }
+      {
+       __glibcxx_assert(__pos != end());
+       return _M_t.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
index 2b56824b4494478d8bca4981b41a8c57d6e5b9b5..c794b9bec4eaa59f9ec56bcff0d7532025599ed4 100644 (file)
@@ -606,7 +606,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_t.extract(__pos); }
+      {
+       __glibcxx_assert(__pos != end());
+       return _M_t.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
index d7312dff621dee9b639bb7426d00e79a8bfd405f..d3219ebf0837c95dec610cbdb1cea47afecd551a 100644 (file)
@@ -549,7 +549,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_t.extract(__pos); }
+      {
+       __glibcxx_assert(__pos != end());
+       return _M_t.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
index fd96dd4bb583a2b9fec86963c9d507823db3fffd..140db39c9f6d324bb4563d0f1e9d8a98b51ca36f 100644 (file)
@@ -565,7 +565,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_t.extract(__pos); }
+      {
+       __glibcxx_assert(__pos != end());
+       return _M_t.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
index ab8a7621e0dfba7b17a7a577ee7acc1ac2c160e6..6776090e372a5e440d0aeaba551ee0282ece9af7 100644 (file)
@@ -421,7 +421,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_h.extract(__pos); }
+      {
+       __glibcxx_assert(__pos != end());
+       return _M_h.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
@@ -1534,7 +1537,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_h.extract(__pos); }
+      {
+       __glibcxx_assert(__pos != end());
+       return _M_h.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
index e5bb2beb80da01ef05ff3367989f137bc345fbed..99052575d99a4fc1e773b5f58f98f1801fb17bc8 100644 (file)
@@ -482,7 +482,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_h.extract(__pos); }
+      {
+       __glibcxx_assert(__pos != end());
+       return _M_h.extract(__pos);
+      }
 
       /// Extract a node.
       node_type
@@ -1190,7 +1193,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       /// Extract a node.
       node_type
       extract(const_iterator __pos)
-      { return _M_h.extract(__pos); }
+      {
+       __glibcxx_assert(__pos != end());
+       return _M_h.extract(__pos);
+      }
 
       /// Extract a node.
       node_type