]> 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>
Tue, 15 Nov 2011 23:28:49 +0000 (23:28 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 15 Nov 2011 23:28:49 +0000 (23:28 +0000)
2011-11-15  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: r181394

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 e4a09a5e587ffcbc47fb00cc1f38c6de3a2ee01f..60602ebbb3ee1200db359ccc4ddf3e65658824b7 100644 (file)
@@ -1,3 +1,28 @@
+2011-11-15  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 95d06b21262e847cade69071bbe135c44a29bd4c..203999d9ca04c5bef069dcf79849b2de27f9b243 100644 (file)
@@ -432,6 +432,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 45824f04079fb0e141adeef6710206a20e656579..f1c4cfefa57ac98189345175f6afca89c1622986 100644 (file)
@@ -617,6 +617,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 fd5a5a8cffba892fe067f93d827aa39827404f1b..ae4389e2709d9b7fd48afcd3d18b94509b5aeeb0 100644 (file)
@@ -536,6 +536,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 8c5f0c30a0f55e04244fc0c2d0fce98e54700573..ee56bbc75256c94f825f3ca3070131b75d36011d 100644 (file)
@@ -767,6 +767,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 e80c1e3b4b7a2af27492d6778b219329d86a64a4..9abfee867d00ad318ccef88a3045f60c452fe9ab 100644 (file)
@@ -271,6 +271,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 cf18d7cc1140e6d1d7af8037907c1b45a81aa6f9..e43094f8b4df99df0fe7fbdc3c92c6e30b475af9 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 6eeff6429e459bb0825fdf0433df3c820dfef8b4..9a6061e69cecdd9b8d915ad0690fccbc764eb9e6 100644 (file)
@@ -333,6 +333,10 @@ namespace __debug
        return iterator(__next, this);
       }
 
+      iterator
+      erase(iterator __it)
+      { return erase(const_iterator(__it)); }
+
       iterator
       erase(const_iterator __first, const_iterator __last)
       {
@@ -708,6 +712,10 @@ namespace __debug
        return iterator(__next, this);
       }
 
+      iterator
+      erase(iterator __it)
+      { return erase(const_iterator(__it)); }
+
       iterator
       erase(const_iterator __first, const_iterator __last)
       {
index 0cc3a12cf377e74d93fb0faaf29148775daf981a..ce169e66cb3810133da36db6055c9708fb5fced7 100644 (file)
@@ -329,6 +329,10 @@ namespace __debug
        return iterator(__next, this);
       }
 
+      iterator
+      erase(iterator __it)
+      { return erase(const_iterator(__it)); }
+
       iterator
       erase(const_iterator __first, const_iterator __last)
       {
@@ -695,6 +699,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 622bc575ad2d12812a9790d4f8fb03c990634f5d..eb5c5d90d9c6770ff7e8dd8502192c75d96d77c7 100644 (file)
@@ -327,6 +327,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 547a221b3300bfb335cdffc38824b2d6c6ce0cf8..b71be4570bdea575157b06af015226d901b42182 100644 (file)
@@ -226,6 +226,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);
+}