On 16 April 2012 21:28, Jonathan Wakely wrote: > I have a patch to add the checks to <debug/forward_list>
And here it is, only checking in debug mode because noone objected to that suggestion. * 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. Tested x86_64-linux, committed to trunk.
commit 9b07baf113d864170679189e5269ccaad2992cc8 Author: Jonathan Wakely <jwakely....@gmail.com> Date: Tue Apr 17 00:10:50 2012 +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. diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list index f4a7ee9..8ad4336 100644 --- a/libstdc++-v3/include/debug/forward_list +++ b/libstdc++-v3/include/debug/forward_list @@ -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) diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc index 0c746c1..f0ab4bc 100644 --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -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 index 0000000..6b7d0da --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc @@ -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 index 0000000..620bb5c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc @@ -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 index 0000000..a2b5cfa --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc @@ -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; +} commit 61cb2bc306111a3ddde8383a208142255ce75210 Author: uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Sun Apr 22 12:58:59 2012 +0000 * ChangeLog: Fix. * testsuite/ChangeLog: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186668 138bc75d-0d04-0410-961f-82ee72b054a4