Implement LWG-4259 P1148R0 changed the return values of searching functions of std::basic_string on some platforms - #6236
Merged
Stephan T. Lavavej (StephanTLavavej) merged 19 commits intoJul 21, 2026
Conversation
…nctions of std::basic_string on some platforms
Copilot started reviewing on behalf of
Stephan T. Lavavej (StephanTLavavej)
April 29, 2026 06:37
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Implements the LWG-4259/P1148R0 behavior change so std::basic_string searching functions return basic_string::npos (not a truncated size_t(-1)/string_view::npos) when basic_string::size_type is wider than size_t, and adds a regression test for that scenario.
Changes:
- Add an internal helper to cast search results from
size_ttobasic_string::size_type, mappingsize_t(-1)tobasic_string::nposwhen needed. - Update all
basic_stringsearch-family functions (find*/rfind*) to use the helper. - Add a test using a custom allocator with a wider
size_typeto validatenposreturn values.
Show a summary per file
| File | Description |
|---|---|
| tests/std/tests/GH_005546_containers_size_type_cast/test.cpp | Adds a wide-size_type allocator + new test cases covering basic_string search functions returning npos. |
| stl/inc/xstring | Fixes return-value casting for basic_string searching functions when size_type is wider than size_t. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 3
Copilot started reviewing on behalf of
Stephan T. Lavavej (StephanTLavavej)
July 20, 2026 19:46
View session
Member
|
Thanks! 😻 I pushed a bunch of nitpicky changes. |
Stephan T. Lavavej (StephanTLavavej)
approved these changes
Jul 20, 2026
Member
|
I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required. |
Stephan T. Lavavej (StephanTLavavej)
merged commit Jul 21, 2026
3a79198
into
microsoft:main
49 checks passed
Member
|
Thanks for implementing this LWG issue resolution, and apologies for how long it took to review this! 😹 🎉 🚀 |
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.
Fixes #6208.