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

[libc++] Add input validation for set_intersection() in debug mode. #101508

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Aug 1, 2024

  1. [libc++] Add input validation for set_intersection() in debug mode.

    The use of one-sided binary search introduced by a066217 changes behaviour on invalid, unsorted input (see llvm#75230 (comment)). Add input validation on `_LIBCPP_HARDENING_MODE_DEBUG` to help users.
    
    * Change interface of `__is_sorted_until()` so that it accepts a sentinel that's of a different type than the beginning iterator, and to ensure it won't try to copy the comparison function object.
    * Add one assertion for each input range confirming that they are sorted.
    * Stop validating complexity of `set_intersection()` in debug mode, it's hopeless and also not meaningful: there are no complexity guarantees in debug mode, we're happy to trade performance for diagnosability.
    * Fix bugs in `ranges_robust_against_differing_projections.pass`: we were using an input range as output for `std::ranges::partial_sort_copy()`, and using projections which return the opposite value means that algorithms requiring a sorted range can't use ranges sorted with ascending values if the comparator is `std::ranges::less`. Added `const` where appropriate to make sure we weren't using inputs as outputs in other places.
    ichaer committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    5620dce View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7f2beae View commit details
    Browse the repository at this point in the history

Commits on Aug 2, 2024

  1. Addressing @alexfh's feedback.

    ichaer committed Aug 2, 2024
    Configuration menu
    Copy the full SHA
    3006f13 View commit details
    Browse the repository at this point in the history