]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/51142 ([C++0x] map::erase(key) doesn't compile with -D_GLIBCXX_DEBUG.)
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 16 Nov 2011 23:11:26 +0000 (23:11 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 16 Nov 2011 23:11:26 +0000 (23:11 +0000)
2011-11-16  Paolo Carlini  <paolo.carlini@oracle.com>

PR libstdc++/51142
* include/debug/unordered_map (unordered_map<>::erase(iterator),
unordered_multimap<>::erase(iterator)): Add, consistently with
LWG 2059.
* include/debug/unordered_set (unordered_set<>::erase(iterator),
unordered_multiset<>::erase(iterator)): Likewise.
* include/debug/map.h (map<>::erase(iterator)): Likewise.
* include/debug/multimap.h (multimap<>::erase(iterator)): Likewise.
* include/profile/map.h (map<>::erase(iterator)): Likewise.
* include/profile/multimap.h (multimap<>::erase(iterator)): Likewise.
* include/bits/hashtable.h (_Hashtable<>::erase(iterator)): Likewise.
* include/bits/stl_map.h (map<>::erase(iterator)): Likewise.
* include/bits/stl_multimap.h (multimap<>::erase(iterator)): Likewise.
* include/bits/stl_tree.h (_Rb_tree<>::erase(iterator)): Likewise.
* testsuite/23_containers/unordered_map/erase/51142.cc: New.
* testsuite/23_containers/multimap/modifiers/erase/51142.cc: Likewise.
* testsuite/23_containers/set/modifiers/erase/51142.cc: Likewise.
* testsuite/23_containers/unordered_multimap/erase/51142.cc: Likewise.
* testsuite/23_containers/unordered_set/erase/51142.cc: Likewise.
* testsuite/23_containers/multiset/modifiers/erase/51142.cc: Likewise.
* testsuite/23_containers/unordered_multiset/erase/51142.cc: Likewise.
* testsuite/23_containers/map/modifiers/erase/51142.cc: Likewise.

From-SVN: r181427

19 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/hashtable.h
libstdc++-v3/include/bits/stl_map.h
libstdc++-v3/include/bits/stl_multimap.h
libstdc++-v3/include/bits/stl_tree.h
libstdc++-v3/include/debug/map.h
libstdc++-v3/include/debug/multimap.h
libstdc++-v3/include/debug/unordered_map
libstdc++-v3/include/debug/unordered_set
libstdc++-v3/include/profile/map.h
libstdc++-v3/include/profile/multimap.h
libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc [new file with mode: 0644]

index 1a8b52e5219d3e0fe68a388120d92fce9d55683d..d668b14f0fbee4c3c58ab63aea800f1a6ca863c6 100644 (file)
@@ -1,3 +1,28 @@
+2011-11-16  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR libstdc++/51142
+       * include/debug/unordered_map (unordered_map<>::erase(iterator),
+       unordered_multimap<>::erase(iterator)): Add, consistently with
+       LWG 2059.
+       * include/debug/unordered_set (unordered_set<>::erase(iterator),
+       unordered_multiset<>::erase(iterator)): Likewise.
+       * include/debug/map.h (map<>::erase(iterator)): Likewise.
+       * include/debug/multimap.h (multimap<>::erase(iterator)): Likewise.
+       * include/profile/map.h (map<>::erase(iterator)): Likewise.
+       * include/profile/multimap.h (multimap<>::erase(iterator)): Likewise.
+       * include/bits/hashtable.h (_Hashtable<>::erase(iterator)): Likewise.
+       * include/bits/stl_map.h (map<>::erase(iterator)): Likewise.
+       * include/bits/stl_multimap.h (multimap<>::erase(iterator)): Likewise.
+       * include/bits/stl_tree.h (_Rb_tree<>::erase(iterator)): Likewise.
+       * testsuite/23_containers/unordered_map/erase/51142.cc: New.
+       * testsuite/23_containers/multimap/modifiers/erase/51142.cc: Likewise.
+       * testsuite/23_containers/set/modifiers/erase/51142.cc: Likewise.
+       * testsuite/23_containers/unordered_multimap/erase/51142.cc: Likewise.
+       * testsuite/23_containers/unordered_set/erase/51142.cc: Likewise.
+       * testsuite/23_containers/multiset/modifiers/erase/51142.cc: Likewise.
+       * testsuite/23_containers/unordered_multiset/erase/51142.cc: Likewise.
+       * testsuite/23_containers/map/modifiers/erase/51142.cc: Likewise.
+
 2011-11-15  Jason Dick  <dickphd@gmail.com>
 
        PR libstdc++/51133
index b9e7a6eaf49a599a68ca25ec0bfb5821a7f40c98..8fdcfbfc38778df9cf64e73a3be952932fafbd98 100644 (file)
@@ -440,6 +440,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       iterator
       erase(const_iterator);
 
+      // LWG 2059.
+      iterator
+      erase(iterator __it)
+      { return erase(const_iterator(__it)); }
+
       size_type
       erase(const key_type&);
 
index a84b4b61dfb195bd0b922fc2a960a73b5d7aa1a2..a1bef8b6adeccf0c6ecdb246e2e8cd6feec6edad 100644 (file)
@@ -612,6 +612,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       iterator
       erase(const_iterator __position)
       { return _M_t.erase(__position); }
+
+      // LWG 2059.
+      iterator
+      erase(iterator __position)
+      { return _M_t.erase(__position); }
 #else
       /**
        *  @brief Erases an element from a %map.
index ca37f359e1b8b8c105f7a7e89c0eb4b40b3dc624..02e8f58e9c965704b597f65f543b866253f71955 100644 (file)
@@ -533,6 +533,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       iterator
       erase(const_iterator __position)
       { return _M_t.erase(__position); }
+
+      // LWG 2059.
+      iterator
+      erase(iterator __position)
+      { return _M_t.erase(__position); }
 #else
       /**
        *  @brief Erases an element from a %multimap.
index 85681d2da36af76d54b46552c89bc07846bb404a..4001bad57f4ebd6be1dca57750f9ea4fda932b78 100644 (file)
@@ -760,6 +760,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _M_erase_aux(__position);
        return __result._M_const_cast();
       }
+
+      // LWG 2059.
+      iterator
+      erase(iterator __position)
+      {
+       iterator __result = __position;
+       ++__result;
+       _M_erase_aux(__position);
+       return __result;
+      }
 #else
       void
       erase(iterator __position)
index 31085197f3c657684def46a00242c9b4f1ee257b..177797d739c98b3a2f99ff09d25440c016fcbfda 100644 (file)
@@ -273,6 +273,10 @@ namespace __debug
        this->_M_invalidate_if(_Equal(__position.base()));
        return iterator(_Base::erase(__position.base()), this);
       }
+
+      iterator
+      erase(iterator __position)
+      { return erase(const_iterator(__position)); }
 #else
       void
       erase(iterator __position)
index 3c22517b28704d0cec669d798ef0d07a57cb3452..d2e1976990b602efc3b520b24b955f1a26ed9df0 100644 (file)
@@ -254,6 +254,10 @@ namespace __debug
        this->_M_invalidate_if(_Equal(__position.base()));
        return iterator(_Base::erase(__position.base()), this);
       }
+
+      iterator
+      erase(iterator __position)
+      { return erase(const_iterator(__position)); }
 #else
       void
       erase(iterator __position)
index 2d7e100c43eba3d61421305837ed5cec0e12b9be..43b1e9c2900b7fa5c415bddfba3b0efa542748bb 100644 (file)
@@ -275,6 +275,10 @@ namespace __debug
        return iterator(_Base::erase(__it.base()), this);
       }
 
+      iterator
+      erase(iterator __it)
+      { return erase(const_iterator(__it)); }
+
       iterator
       erase(const_iterator __first, const_iterator __last)
       {
@@ -557,6 +561,10 @@ namespace __debug
        return iterator(_Base::erase(__it.base()), this);
       }
 
+      iterator
+      erase(iterator __it)
+      { return erase(const_iterator(__it)); }
+
       iterator
       erase(const_iterator __first, const_iterator __last)
       {
index e30f976d3d624f53d4b31df40fd0a29a826996ff..cf21a3c150a2ca85148b740b83237d0693a1d6a2 100644 (file)
@@ -268,6 +268,10 @@ namespace __debug
        return iterator(_Base::erase(__it.base()), this);
       }
 
+      iterator
+      erase(iterator __it)
+      { return erase(const_iterator(__it)); }
+
       iterator
       erase(const_iterator __first, const_iterator __last)
       {
@@ -538,6 +542,10 @@ namespace __debug
        return iterator(_Base::erase(__it.base()), this);
       }
 
+      iterator
+      erase(iterator __it)
+      { return erase(const_iterator(__it)); }
+
       iterator
       erase(const_iterator __first, const_iterator __last)
       {
index 1edc16c787919e2c0f1ae9b5ce92f28cae2f12f1..a58a2b01a9bc0feac845adab857270a824ba5cea 100644 (file)
@@ -326,6 +326,10 @@ namespace __profile
         __profcxx_map_to_unordered_map_erase(this, size(), 1);
         return __i;
       }
+
+      iterator
+      erase(iterator __position)
+      { return erase(const_iterator(__position)); }
 #else
       void
       erase(iterator __position)
index 76ce805f3d73d6546cb8262d3dc1edb6c4184d14..3ee169b24db47ceb1cf59ed27092f22c6d938515 100644 (file)
@@ -225,6 +225,10 @@ namespace __profile
       iterator
       erase(const_iterator __position)
       { return iterator(_Base::erase(__position)); }
+
+      iterator
+      erase(iterator __position)
+      { return iterator(_Base::erase(__position)); }
 #else
       void
       erase(iterator __position)
diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc
new file mode 100644 (file)
index 0000000..f50b7b7
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <map>
+
+struct X
+{
+  template<typename T>
+  X(T&) {}
+};
+
+bool operator<(const X&, const X&) { return false; }
+
+// LWG 2059.
+void erasor(std::map<X, int>& s, X x)
+{
+  std::map<X, int>::iterator it = s.find(x);
+  if (it != s.end())
+    s.erase(it);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/erase/51142.cc
new file mode 100644 (file)
index 0000000..ee687f7
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <map>
+
+struct X
+{
+  template<typename T>
+  X(T&) {}
+};
+
+bool operator<(const X&, const X&) { return false; }
+
+// LWG 2059.
+void erasor(std::multimap<X, int>& s, X x)
+{
+  std::multimap<X, int>::iterator it = s.find(x);
+  if (it != s.end())
+    s.erase(it);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/multiset/modifiers/erase/51142.cc
new file mode 100644 (file)
index 0000000..c5beb6a
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <set>
+
+struct X
+{
+  template<typename T>
+  X(T&) {}
+};
+
+bool operator<(const X&, const X&) { return false; }
+
+// LWG 2059.
+void erasor(std::multiset<X>& s, X x)
+{
+  std::multiset<X>::iterator it = s.find(x);
+  if (it != s.end())
+    s.erase(it);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/erase/51142.cc
new file mode 100644 (file)
index 0000000..4fb296a
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <set>
+
+struct X
+{
+  template<typename T>
+  X(T&) {}
+};
+
+bool operator<(const X&, const X&) { return false; }
+
+// LWG 2059.
+void erasor(std::set<X>& s, X x)
+{
+  std::set<X>::iterator it = s.find(x);
+  if (it != s.end())
+    s.erase(it);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/erase/51142.cc
new file mode 100644 (file)
index 0000000..eab637d
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <unordered_map>
+
+struct X
+{
+  template<typename T>
+  X(T&) {}
+};
+
+bool operator==(const X&, const X&) { return false; }
+
+// LWG 2059.
+void erasor(std::unordered_map<X, int>& s, X x)
+{
+  std::unordered_map<X, int>::iterator it = s.find(x);
+  if (it != s.end())
+    s.erase(it);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/erase/51142.cc
new file mode 100644 (file)
index 0000000..678aa5d
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <unordered_map>
+
+struct X
+{
+  template<typename T>
+  X(T&) {}
+};
+
+bool operator==(const X&, const X&) { return false; }
+
+// LWG 2059.
+void erasor(std::unordered_multimap<X, int>& s, X x)
+{
+  std::unordered_multimap<X, int>::iterator it = s.find(x);
+  if (it != s.end())
+    s.erase(it);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/erase/51142.cc
new file mode 100644 (file)
index 0000000..4db6af0
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <unordered_set>
+
+struct X
+{
+  template<typename T>
+  X(T&) {}
+};
+
+bool operator==(const X&, const X&) { return false; }
+
+// LWG 2059.
+void erasor(std::unordered_multiset<X>& s, X x)
+{
+  std::unordered_multiset<X>::iterator it = s.find(x);
+  if (it != s.end())
+    s.erase(it);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/erase/51142.cc
new file mode 100644 (file)
index 0000000..1486460
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+#include <unordered_set>
+
+struct X
+{
+  template<typename T>
+  X(T&) {}
+};
+
+bool operator==(const X&, const X&) { return false; }
+
+// LWG 2059.
+void erasor(std::unordered_set<X>& s, X x)
+{
+  std::unordered_set<X>::iterator it = s.find(x);
+  if (it != s.end())
+    s.erase(it);
+}