https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117121
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:27f6b376e8e196c7c85c8b47436cd2f2993768da commit r15-4303-g27f6b376e8e196c7c85c8b47436cd2f2993768da Author: Jonathan Wakely <jwak...@redhat.com> Date: Sun Oct 13 19:14:04 2024 +0100 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.