[libcxx-commits] [pstl] [pstl] Fix comparison function passed to std::inplace_merge (PR #80265)

Jonathan Wakely via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 1 02:36:21 PST 2024


https://github.com/jwakely created https://github.com/llvm/llvm-project/pull/80265

This needs to be an ordering, not an equality comparison.

Fixes #80217

>From 86390895753fc7d914cfee02a6b8331cc3dfcbfe Mon Sep 17 00:00:00 2001
From: Jonathan Wakely <jwakely at redhat.com>
Date: Thu, 1 Feb 2024 10:27:10 +0000
Subject: [PATCH] [pstl] Fix comparison function passed to std::inplace_merge

This needs to be an ordering, not an equality comparison.

Fixes #80217
---
 pstl/test/std/algorithms/alg.merge/inplace_merge.pass.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pstl/test/std/algorithms/alg.merge/inplace_merge.pass.cpp b/pstl/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
index 3446d955093ad..4d706f067b183 100644
--- a/pstl/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
+++ b/pstl/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
@@ -150,7 +150,7 @@ main()
     test_by_type<MemoryChecker>(
         [](std::size_t idx){ return MemoryChecker{std::int32_t(idx * 2)}; },
         [](std::size_t idx){ return MemoryChecker{std::int32_t(idx * 2 + 1)}; },
-        [](const MemoryChecker& val1, const MemoryChecker& val2){ return val1.value() == val2.value(); });
+        [](const MemoryChecker& val1, const MemoryChecker& val2){ return val1.value() < val2.value(); });
     EXPECT_FALSE(MemoryChecker::alive_objects() < 0, "wrong effect from inplace_merge: number of ctors calls < num of dtors calls");
     EXPECT_FALSE(MemoryChecker::alive_objects() > 0, "wrong effect from inplace_merge: number of ctors calls > num of dtors calls");
 



More information about the libcxx-commits mailing list