]> 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, 15 Jun 2022 08:12:09 +0000 (09:12 +0100)
commitd4fdb293004f2e104edf823d4820d4ee73aa2660
treea588822da128d26128459d44f3089f45e1674887
parent24551c8642150bbf51cdb1f740ad59a1a57be294
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/multiset/allocator/103501.cc: New test.
* testsuite/23_containers/set/allocator/103501.cc: New test.

(cherry picked from commit 056551414a328b427c4bf4955b9a3832f344685c)
libstdc++-v3/include/bits/stl_tree.h
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]