libstdc++: Make __gnu_cxx::sequence_buffer move-aware [PR101542]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 21 Jul 2021 14:29:19 +0000 (15:29 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 21 Jul 2021 16:20:37 +0000 (17:20 +0100)
commit8edb61420502c62fa2cccdd98876a9aa039b72a6
tree571f02297c927569f8aff7ad4a254fc8a4837a64
parente4d306cf706eef83f99d510c308eda1539d05875
libstdc++: Make __gnu_cxx::sequence_buffer move-aware [PR101542]

The PR explains that Clang trunk now selects a different constructor
when a non-const sequence_buffer is returned in a context where it
qualifies as an implicitly-movable entity. Because lookup is first
performed using an rvalue, the sequence_buffer(const sequence_buffer&)
constructor gets chosen, which makes a copy instead of a "pseudo-move"
via the sequence_buffer(sequence_buffer&) constructor. The problem isn't
seen with GCC because as noted in the r11-2412 commit log, GCC actually
implements a slightly modified rule that avoids breaking exactly this
type of code.

This patch adds a move constructor to sequence_buffer, so that implicit
or explicit moves will have the same effect, calling the
sequence_buffer(sequence_buffer&) constructor. A move assignment
operator is also added to make move assignment work similarly.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/101542
* include/ext/rope (sequence_buffer): Add move constructor and
move assignment operator.
* testsuite/ext/rope/101542.cc: New test.
libstdc++-v3/include/ext/rope
libstdc++-v3/testsuite/ext/rope/101542.cc [new file with mode: 0644]