[libcxx-commits] [PATCH] D154913: [libc++][PSTL] Fix double-move in std::transform_reduce
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 12 08:56:32 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
philnik marked 2 inline comments as done.
Closed by commit rGa70ce8cb0e4b: [libc++][PSTL] Fix double-move in std::transform_reduce (authored by philnik).
Changed prior to commit:
https://reviews.llvm.org/D154913?vs=538887&id=539590#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154913/new/
https://reviews.llvm.org/D154913
Files:
libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h
libcxx/test/std/algorithms/numeric.ops/transform.reduce/pstl.transform_reduce.unary.pass.cpp
Index: libcxx/test/std/algorithms/numeric.ops/transform.reduce/pstl.transform_reduce.unary.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/numeric.ops/transform.reduce/pstl.transform_reduce.unary.pass.cpp
+++ 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 <numeric>
+#include <string>
#include <vector>
#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<decltype(ret), ValueT>);
assert(ret == expected);
}
Index: libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h
===================================================================
--- libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h
+++ 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{},
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154913.539590.patch
Type: text/x-patch
Size: 1979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230712/e7622b7e/attachment-0001.bin>
More information about the libcxx-commits
mailing list