Skip to content

Sorted array operations do not validate sortedness #2832

@huitseeker

Description

@huitseeker

In the standard library, procedures like std::array::binary_search and related sorted-array helpers assume the input is sorted but do not validate this precondition. If passed an unsorted array:

  1. Binary search may return incorrect results or infinite loop
  2. Insertion may produce a still-unsorted array

The documentation states the input must be sorted, so this is expected behavior. However, users may be surprised that invalid input produces silent corruption rather than an error.

Recommendation: either document this more prominently, or add a debug-mode assertion that checks sortedness on entry.

Metadata

Metadata

Assignees

Labels

corelibRelated to Miden VM core librarydocumentationImprovements or additions to documentation

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions