summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-07 14:12:06 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-07 14:12:06 +0000
commit74508cc2595ad8a81ffed760353a5a5499001e34 (patch)
tree8ea5a9e6b5132a818b56b5501ae8a37168abf64f /libstdc++-v3
parenta6c1206fd768a51d7434585763b872f74949c41e (diff)
downloadppe42-gcc-74508cc2595ad8a81ffed760353a5a5499001e34.tar.gz
ppe42-gcc-74508cc2595ad8a81ffed760353a5a5499001e34.zip
PR libstdc++/61023
* include/bits/stl_tree.h (_Rb_tree::_M_move_assign): Copy the comparison function. * testsuite/23_containers/set/cons/61023.cc: New. PR libstdc++/61023 * include/bits/stl_tree.h (_Rb_tree::_M_move_assign): Copy the comparison function. * testsuite/23_containers/set/cons/61023.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@210158 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/stl_tree.h1
-rw-r--r--libstdc++-v3/testsuite/23_containers/set/cons/61023.cc56
3 files changed, 64 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 58771cb934e..9a5505eb236 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2014-05-07 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/61023
+ * include/bits/stl_tree.h (_Rb_tree::_M_move_assign): Copy the
+ comparison function.
+ * testsuite/23_containers/set/cons/61023.cc: New.
+
2014-05-06 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline
diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
index 4bc3c602c20..cac917ea35b 100644
--- a/libstdc++-v3/include/bits/stl_tree.h
+++ b/libstdc++-v3/include/bits/stl_tree.h
@@ -1073,6 +1073,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
_M_move_assign(_Rb_tree& __x)
{
+ _M_impl._M_key_compare = __x._M_impl._M_key_compare;
if (_Alloc_traits::_S_propagate_on_move_assign()
|| _Alloc_traits::_S_always_equal()
|| _M_get_Node_allocator() == __x._M_get_Node_allocator())
diff --git a/libstdc++-v3/testsuite/23_containers/set/cons/61023.cc b/libstdc++-v3/testsuite/23_containers/set/cons/61023.cc
new file mode 100644
index 00000000000..087b9cc188a
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/set/cons/61023.cc
@@ -0,0 +1,56 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2014 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/>.
+
+#include <set>
+#include <stdexcept>
+
+struct Comparator
+{
+ Comparator() : valid(false) { }
+ explicit Comparator(bool) : valid(true) { }
+
+ bool operator()(int i, int j) const
+ {
+ if (!valid)
+ throw std::logic_error("Comparator is invalid");
+ return i < j;
+ }
+
+private:
+ bool valid;
+};
+
+int main()
+{
+ using test_type = std::set<int, Comparator>;
+
+ Comparator cmp{true};
+
+ test_type good{cmp};
+
+ test_type s1;
+ s1 = good; // copy-assign
+ s1.insert(1);
+ s1.insert(2);
+
+ test_type s2;
+ s2 = std::move(good); // move-assign
+ s2.insert(1);
+ s2.insert(2);
+}
OpenPOWER on IntegriCloud