diff --git a/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h b/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h --- a/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h +++ b/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h @@ -163,7 +163,7 @@ std::move(__last), [__transform](_ForwardIterator __iter) { return __transform(*__iter); }, std::move(__init), - std::move(__reduce), + __reduce, [=](_ForwardIterator __brick_first, _ForwardIterator __brick_last, _Tp __brick_init) { return std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>( __cpu_backend_tag{}, diff --git a/libcxx/test/std/algorithms/numeric.ops/transform.reduce/pstl.transform_reduce.unary.pass.cpp b/libcxx/test/std/algorithms/numeric.ops/transform.reduce/pstl.transform_reduce.unary.pass.cpp --- a/libcxx/test/std/algorithms/numeric.ops/transform.reduce/pstl.transform_reduce.unary.pass.cpp +++ b/libcxx/test/std/algorithms/numeric.ops/transform.reduce/pstl.transform_reduce.unary.pass.cpp @@ -20,6 +20,7 @@ // T init, BinaryOperation binary_op, UnaryOperation unary_op); #include +#include #include #include "MoveOnly.h" @@ -42,8 +43,14 @@ Iter1(std::data(a)), Iter1(std::data(a) + std::size(a)), ValueT(34), - [](ValueT i, ValueT j) { return i + j; }, - [](ValueT i) { return i + 1; }); + [check = std::string("Banane")](ValueT i, ValueT j) { + assert(check == "Banane"); // ensure that no double-moves happen + return i + j; + }, + [check = std::string("Banane")](ValueT i) { + assert(check == "Banane"); // ensure that no double-moves happen + return i + 1; + }); static_assert(std::is_same_v); assert(ret == expected); }