]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Clear RB tree after moving elements [PR103501]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 30 Nov 2021 23:32:50 +0000 (23:32 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 1 Dec 2021 15:00:33 +0000 (15:00 +0000)
commit056551414a328b427c4bf4955b9a3832f344685c
treed13b6156601699c3c45d360aceea73da5fa4320c
parent74d14778e73dfda365b0ac71478efafd9ad91c2a
libstdc++: Clear RB tree after moving elements [PR103501]

If the allocator-extended move constructor move-constructs each element
into the new container, the contents of the old container are left in
moved-from states. We cannot know if those states preserve the
container's ordering and uniqueness guarantees, so just erase all
moved-from elements.

libstdc++-v3/ChangeLog:

PR libstdc++/103501
* include/bits/stl_tree.h (_Rb_tree(_Rb_tree&&, false_type)):
Clear container if elements have been moved-from.
* testsuite/23_containers/map/allocator/move_cons.cc: Expect
moved-from container to be empty.
* testsuite/23_containers/multimap/allocator/move_cons.cc:
Likewise.
* testsuite/23_containers/multiset/allocator/103501.cc: New test.
* testsuite/23_containers/set/allocator/103501.cc: New test.
libstdc++-v3/include/bits/stl_tree.h
libstdc++-v3/testsuite/23_containers/map/allocator/move_cons.cc
libstdc++-v3/testsuite/23_containers/multimap/allocator/move_cons.cc
libstdc++-v3/testsuite/23_containers/multiset/allocator/103501.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/set/allocator/103501.cc [new file with mode: 0644]