]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR libstdc++/92124 fix incorrect container move assignment
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Oct 2019 14:21:27 +0000 (14:21 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Oct 2019 14:21:27 +0000 (14:21 +0000)
commit2bd0f173113ab286c55c94f4867af3965797de0d
tree3613ae6f84da1b3ebd3fbbf1e137b4286ffb4dc1
parentd0efda0cbe5df0a92b437be15afd1f4d781f7b8b
PR libstdc++/92124 fix incorrect container move assignment

The container requirements say that for move assignment "All existing
elements of [the target] are either move assigned or destroyed". Some of
our containers currently use __make_move_if_noexcept which makes the
move depend on whether the element type is nothrow move constructible.
This is incorrect, because the standard says we must move assign, not
move or copy depending on the move constructor.

Use make_move_iterator instead so that we move unconditionally. This
ensures existing elements won't be copy assigned.

PR libstdc++/92124
* include/bits/forward_list.h
(_M_move_assign(forward_list&&, false_type)): Do not use
__make_move_if_noexcept, instead move unconditionally.
* include/bits/stl_deque.h (_M_move_assign2(deque&&, false_type)):
Likewise.
* include/bits/stl_list.h (_M_move_assign(list&&, false_type)):
Likewise.
* include/bits/stl_vector.h (_M_move_assign(vector&&, false_type)):
Likewise.
* testsuite/23_containers/vector/92124.cc: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@277113 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/forward_list.h
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/include/bits/stl_list.h
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/testsuite/23_containers/deque/92124.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/92124.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/list/92124.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/92124.cc [new file with mode: 0644]