Repository navigation
Conversation
The parallel implementation of any_of returned true when first == last, like all_of and none_of do. For any_of the result has to be false, since no element of an empty range satisfies the predicate. This affected hpx::any_of and hpx::ranges::any_of with par, par_unseq and the task policies; the sequential path was already correct. Add empty-range checks to the parallel, ranges and async tests. Signed-off-by: Ishaan400 <[email protected]>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Correct and test empty-range results libs/core/algorithms/include/hpx/parallel/algorithms/all_any_none.hpp, libs/core/algorithms/tests/unit/algorithms/any_of_tests.hpp |
The fast path returns false for an empty range. Tests check policy-based, ranges, and asynchronous any_of calls with an always-true predicate. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested labels: type: defect, category: algorithms
Merge Risk: 
Minimal · up to d909f
-
No actionable merge-blocking risk is established by the supplied change context.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Up to standards ✅🟢 Issues
|
Proposed Changes
falseinstead oftruefrom the empty-range shortcut in the parallelany_of. The shortcut is the same as the one inall_ofandnone_of, wheretrueis right, butany_ofof an empty range has to befalse.any_oftests.Any background context you want to provide?
hpx::any_of(hpx::execution::par, v.begin(), v.end(), pred)with an emptyvreturnedtrue, while the sequential version andstd::any_ofreturnfalse. The same happened forpar_unseq,hpx::ranges::any_ofand the task policies, since they go through the same code.I came across this while comparing the parallel algorithms with the standard library on random inputs. Without the fix, 10 of the new checks fail; with it, the
any_of,any_of_rangeandany_of_sendertests pass.Checklist
Not all points below apply to all pull requests.