diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-09-10 14:25:41 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-09-10 18:22:32 +0100 |
commit | c07cf418fdde0c192e370a8d76a991cc7215e9c4 (patch) | |
tree | cfc6067cedb0b43f234cbdc21a9c3e17b15e7c7e /gcc/tree-vect-patterns.cc | |
parent | 0008050b9d6046ba4e811a03b406fb5d98707cae (diff) | |
download | gcc-c07cf418fdde0c192e370a8d76a991cc7215e9c4.zip gcc-c07cf418fdde0c192e370a8d76a991cc7215e9c4.tar.gz gcc-c07cf418fdde0c192e370a8d76a991cc7215e9c4.tar.bz2 |
libstdc++: std::string move assignment should not use POCCA trait [PR116641]
The changes to implement LWG 2579 (r10-327-gdb33efde17932f) made
std::string::assign use the propagate_on_container_copy_assignment
(POCCA) trait, for consistency with operator=(const basic_string&).
However, this also unintentionally affected operator=(basic_string&&)
which calls assign(str) to make a deep copy when performing a move is
not possible. The fix is for the move assignment operator to call
_M_assign(str) instead of assign(str), as this just does the deep copy
and doesn't check the POCCA trait first.
The bug only affects the unlikely/useless combination of POCCA==true and
POCMA==false, but we should fix it for correctness anyway. it should
also make move assignment slightly cheaper to compile and execute,
because we skip the extra code in assign(const basic_string&).
libstdc++-v3/ChangeLog:
PR libstdc++/116641
* include/bits/basic_string.h (operator=(basic_string&&)): Call
_M_assign instead of assign.
* testsuite/21_strings/basic_string/allocator/116641.cc: New
test.
Diffstat (limited to 'gcc/tree-vect-patterns.cc')
0 files changed, 0 insertions, 0 deletions