]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix ranges::copy_backward for a single memcpyable element [PR117121]
authorJonathan Wakely <jwakely@redhat.com>
Sun, 13 Oct 2024 18:14:04 +0000 (19:14 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Sun, 13 Oct 2024 18:27:23 +0000 (19:27 +0100)
commit27f6b376e8e196c7c85c8b47436cd2f2993768da
tree70ad8c01b4fb74bd8e886d5c94f25548d130ec25
parent2ef62aa1a3fb7ece56b0f7a8ba79ef7eac0991ec
libstdc++: Fix ranges::copy_backward for a single memcpyable element [PR117121]

The result iterator needs to be decremented before writing to it.

Improve the PR 108846 tests for all of std::copy, std::copy_n,
std::copy_backward, and the std::ranges versions.

libstdc++-v3/ChangeLog:

PR libstdc++/117121
* include/bits/ranges_algobase.h (copy_backward): Decrement
output iterator before assigning one element through it.
* testsuite/25_algorithms/copy/108846.cc: Ensure the algorithm's
effects are correct for a single memcpyable element.
* testsuite/25_algorithms/copy_backward/108846.cc: Likewise.
* testsuite/25_algorithms/copy_n/108846.cc: Likewise.
libstdc++-v3/include/bits/ranges_algobase.h
libstdc++-v3/testsuite/25_algorithms/copy/108846.cc
libstdc++-v3/testsuite/25_algorithms/copy_backward/108846.cc
libstdc++-v3/testsuite/25_algorithms/copy_n/108846.cc