]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix <numeric> parallel algos for move-only values [PR117905]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 4 Dec 2024 21:50:22 +0000 (21:50 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 6 May 2025 16:19:26 +0000 (17:19 +0100)
commitdf1d436d17c8280bd835b045bd7babf5058a7154
tree329add55a50d580e3d1b7d4b71a157c00b423bd3
parenta067cbcdcc5f599a2b7d607e89674533d23c652d
libstdc++: Fix <numeric> parallel algos for move-only values [PR117905]

All of reduce, transform_reduce, exclusive_scan, and inclusive_scan,
transform_exclusive_scan, and transform_inclusive_scan have a
precondition that the type of init meets the Cpp17MoveConstructible
requirements. It isn't required to be copy constructible, so when
passing it to the next internal function it needs to be moved, not
copied. We also need to move when creating local variables on the stack,
and when returning as part of a pair.

libstdc++-v3/ChangeLog:

PR libstdc++/117905
* include/pstl/glue_numeric_impl.h (reduce, transform_reduce)
(transform_reduce, inclusive_scan, transform_exclusive_scan)
(transform_inclusive_scan): Use std::move for __init parameter.
* include/pstl/numeric_impl.h (__brick_transform_reduce)
(__pattern_transform_reduce, __brick_transform_scan)
(__pattern_transform_scan): Likewise.
* include/std/numeric (inclusive_scan, transform_exclusive_scan):
Use std::move to create local copy of the first element.
* testsuite/26_numerics/pstl/numeric_ops/108236.cc: Move test
using move-only type to ...
* testsuite/26_numerics/pstl/numeric_ops/move_only.cc: New test.
libstdc++-v3/include/pstl/glue_numeric_impl.h
libstdc++-v3/include/pstl/numeric_impl.h
libstdc++-v3/include/std/numeric
libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/108236.cc
libstdc++-v3/testsuite/26_numerics/pstl/numeric_ops/move_only.cc [new file with mode: 0644]