Repository navigation
Fix find of an empty substring at the end of a string_view - #63
Merged
Merged
Conversation
fhgffy
marked this pull request as ready for review
October 5, 2026 06:32
martinmoene
added a commit
that referenced
this pull request
Oct 5, 2026
martinmoene
added a commit
that referenced
this pull request
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An empty substring should match at
poswheneverpos <= size(). The nonstd implementation currently returnsnposatpos == size(), including when both views are empty.Handle this valid empty match before the existing boundary check and search-result conversion. The existing nonempty search path and rejection of positions beyond the end remain unchanged.
Add regression coverage for the view, C-string and counted-pointer overloads; default/literal empty views; interior, end, beyond-end and
npospositions; nonempty controls; wide characters; and C++14-and-later constant evaluation.Validation
Tested locally on Linux x86_64 with GCC 14.2.0:
2b39e871c60f615e91f27b52881d9552ce4d0a6c: runtime failures in C++98/11 and four failing constant-expression assertions in C++14/17/20-O0and-O2, using the default search configurationstd::basic_string_view: all 384 checks pass for each C++17/20 ×-O0/-O2run, covering char, wchar_t, char16_t and char32_tClang, MSVC, older compiler versions and remote CI have not been run locally.