Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSTL inplace_merge test uses invalid comparison function #80217

Open
jwakely opened this issue Jan 31, 2024 · 0 comments · May be fixed by #80265
Open

PSTL inplace_merge test uses invalid comparison function #80217

jwakely opened this issue Jan 31, 2024 · 0 comments · May be fixed by #80265
Labels
pstl Issues related to the C++17 Parallel STL test-suite

Comments

@jwakely
Copy link
Contributor

jwakely commented Jan 31, 2024

[](const MemoryChecker& val1, const MemoryChecker& val2){ return val1.value() == val2.value(); });

This gets passed to std::inplace_merge but that requires an ordering comparison, not an equality predicate.

I think the fix is simply:

--- 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");
 
@EugeneZelenko EugeneZelenko added pstl Issues related to the C++17 Parallel STL test-suite and removed new issue labels Jan 31, 2024
jwakely added a commit to jwakely/llvm-project that referenced this issue Feb 1, 2024
This needs to be an ordering, not an equality comparison.

Fixes llvm#80217
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pstl Issues related to the C++17 Parallel STL test-suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants