forward_list (forward_list::splice_after): Check allocators are equal.
authorJonathan Wakely <jwakely.gcc@gmail.com>
Sun, 22 Apr 2012 13:27:16 +0000 (13:27 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Sun, 22 Apr 2012 13:27:16 +0000 (14:27 +0100)
* include/debug/forward_list (forward_list::splice_after): Check
allocators are equal.
* src/c++11/debug.cc: Fix spelling.
* testsuite/23_containers/forward_list/debug/splice_after5_neg.cc:
New.
* testsuite/23_containers/forward_list/debug/splice_after6_neg.cc:
Likewise.
* testsuite/23_containers/forward_list/debug/splice_after7_neg.cc:
Likewise.

From-SVN: r186669

libstdc++-v3/ChangeLog
libstdc++-v3/include/debug/forward_list
libstdc++-v3/src/c++11/debug.cc
libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc [new file with mode: 0644]

index bebc23c0a7cd983db5c31d995292302414c7dd42..fc39c1ef2a9e430e3f0846e919f1db51980f1e2f 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-22  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       * include/debug/forward_list (forward_list::splice_after): Check
+       allocators are equal.
+       * src/c++11/debug.cc: Fix spelling.
+       * testsuite/23_containers/forward_list/debug/splice_after5_neg.cc:
+       New.
+       * testsuite/23_containers/forward_list/debug/splice_after6_neg.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/debug/splice_after7_neg.cc:
+       Likewise.
+
 2012-04-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR libstdc++/53052
index f4a7ee96df0834893a1467ee3b404897c848a45c..8ad4336663e49191cb3d9dc608488d5f489940fe 100644 (file)
@@ -409,6 +409,10 @@ namespace __debug
        _GLIBCXX_DEBUG_VERIFY(&__list != this,
                              _M_message(__gnu_debug::__msg_self_splice)
                              ._M_sequence(*this, "this"));
+       _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(),
+                             _M_message(__gnu_debug::__msg_splice_alloc)
+                             ._M_sequence(*this)
+                             ._M_sequence(__list, "__list"));
        this->_M_transfer_from_if(__list, [&__list](_Base_const_iterator __it)
          {
            return __it != __list._M_base().cbefore_begin()
@@ -433,6 +437,10 @@ namespace __debug
                              _M_message(__gnu_debug::__msg_splice_other)
                              ._M_iterator(__i, "__i")
                              ._M_sequence(__list, "__list"));
+       _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(),
+                             _M_message(__gnu_debug::__msg_splice_alloc)
+                             ._M_sequence(*this)
+                             ._M_sequence(__list, "__list"));
 
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // 250. splicing invalidates iterators
@@ -469,6 +477,10 @@ namespace __debug
                              ._M_sequence(__list, "list")
                              ._M_iterator(__before, "before")
                              ._M_iterator(__last, "last"));
+       _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(),
+                             _M_message(__gnu_debug::__msg_splice_alloc)
+                             ._M_sequence(*this)
+                             ._M_sequence(__list, "__list"));
 
        for (_Base_const_iterator __tmp = std::next(__before.base());
             __tmp != __last.base(); ++__tmp)
index 0c746c1fc379617c0a5f0d6b64ff8e354d4f01a4..f0ab4bc4ec6bb9764b226e6e75d4113bdd53acb2 100644 (file)
@@ -131,7 +131,7 @@ namespace __gnu_debug
     "attempt to flip a singular bitset reference",
     // std::list checks
     "attempt to splice a list into itself",
-    "attempt to splice lists with inequal allocators",
+    "attempt to splice lists with unequal allocators",
     "attempt to splice elements referenced by a %1.state; iterator",
     "attempt to splice an iterator from a different container",
     "splice destination %1.name;"
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc
new file mode 100644 (file)
index 0000000..6b7d0da
--- /dev/null
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-debug-mode "" }
+// { dg-do run { xfail *-*-* } }
+
+// Copyright (C) 2012 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 Pred 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/>.
+
+#include <forward_list>
+#include <testsuite_allocator.h>
+
+void
+test01()
+{
+  typedef __gnu_test::uneq_allocator<int> alloc_type;
+
+  std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1));
+  std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2));
+
+  fl1.splice_after(fl1.before_begin(), fl2);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc
new file mode 100644 (file)
index 0000000..620bb5c
--- /dev/null
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-debug-mode "" }
+// { dg-do run { xfail *-*-* } }
+
+// Copyright (C) 2012 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 Pred 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/>.
+
+#include <forward_list>
+#include <testsuite_allocator.h>
+
+void
+test01()
+{
+  typedef __gnu_test::uneq_allocator<int> alloc_type;
+
+  std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1));
+  std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2));
+
+  fl1.splice_after(fl1.before_begin(), fl2, fl2.begin());
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc
new file mode 100644 (file)
index 0000000..a2b5cfa
--- /dev/null
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-debug-mode "" }
+// { dg-do run { xfail *-*-* } }
+
+// Copyright (C) 2012 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 Pred 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/>.
+
+#include <forward_list>
+#include <testsuite_allocator.h>
+
+void
+test01()
+{
+  typedef __gnu_test::uneq_allocator<int> alloc_type;
+
+  std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1));
+  std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2));
+
+  fl1.splice_after(fl1.before_begin(), fl2, fl2.begin(), fl2.end());
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}