diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-24 15:46:24 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-09-24 15:46:24 +0000 |
commit | 420fe69f193b87e461335ec117e139203909df8e (patch) | |
tree | fb1da80c898e322f44ac7a772516ad08e0aa4292 /libstdc++-v3 | |
parent | b3c76b90ca1e8656e10926b9b3979064700bc8e7 (diff) | |
download | gcc-420fe69f193b87e461335ec117e139203909df8e.tar.gz |
Leave moved-from std::deque in a valid state
PR libstdc++/67707
* include/bits/stl_deque.h (_Deque_base::_M_move_impl): Initialize
empty object.
* testsuite/23_containers/deque/allocator/move.cc: Check moved-from
deque.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228090 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_deque.h | 1 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc | 10 |
3 files changed, 19 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 17d82e3de71..24a60508cce 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2015-09-24 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/67707 + * include/bits/stl_deque.h (_Deque_base::_M_move_impl): Initialize + empty object. + * testsuite/23_containers/deque/allocator/move.cc: Check moved-from + deque. + 2015-09-23 Jonathan Wakely <jwakely@redhat.com> * src/filesystem/ops.cc (canonical): Simplify error handling and diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index f674245b30d..f81ffd97d33 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -644,6 +644,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _Tp_alloc_type __sink __attribute((__unused__)) {std::move(__alloc)}; // Create an empty map that allocates using the moved-from allocator. _Deque_base __empty{__alloc}; + __empty._M_initialize_map(0); // Now safe to modify current allocator and perform non-throwing swaps. _Deque_impl __ret{std::move(_M_get_Tp_allocator())}; _M_impl._M_swap_data(__ret); diff --git a/libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc b/libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc index c8584378cb0..1b8a0e4e2fb 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/allocator/move.cc @@ -36,6 +36,11 @@ void test01() VERIFY(1 == v1.get_allocator().get_personality()); VERIFY(1 == v2.get_allocator().get_personality()); VERIFY( it == v2.begin() ); + + // PR libstdc++/67707 + VERIFY( v1.size() == 0 ); + v1 = test_type(); + VERIFY( v1.size() == 0 ); } void test02() @@ -47,6 +52,11 @@ void test02() test_type v2(std::move(v1), alloc_type(2)); VERIFY(1 == v1.get_allocator().get_personality()); VERIFY(2 == v2.get_allocator().get_personality()); + + // PR libstdc++/67707 + VERIFY( v1.size() == 0 ); + v1 = test_type(); + VERIFY( v1.size() == 0 ); } int main() |