Skip to content

[pstl] Fix comparison function passed to std::inplace_merge #80265

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jwakely
Copy link
Contributor

@jwakely jwakely commented Feb 1, 2024

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

Fixes #80217

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

Fixes llvm#80217
Copy link

github-actions bot commented Feb 1, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 1bbb797e9c7f37aa814b9bbaba2961f730a26891 86390895753fc7d914cfee02a6b8331cc3dfcbfe -- pstl/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
View the diff from clang-format here.
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 4d706f067b..24b210e3fa 100644
--- a/pstl/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
+++ b/pstl/test/std/algorithms/alg.merge/inplace_merge.pass.cpp
@@ -147,10 +147,10 @@ main()
 
     test_algo_basic_single<int32_t>(run_for_rnd_bi<test_non_const<int32_t>>());
 
-    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(); });
+    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(); });
     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");
 

@jwakely
Copy link
Contributor Author

jwakely commented Feb 1, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

I preserved the original formatting, which is locally consistent with the pstl/test/* style. If somebody wants to change that it should be done to the whole file, not just the lines I'm fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PSTL inplace_merge test uses invalid comparison function
1 participant