Implement LWG-4249 The past end issue for lazy_split_view - #6463
Open
zika (tycket033-tech) wants to merge 3 commits into
Open
zika (tycket033-tech) wants to merge 3 commits into
zika (tycket033-tech) wants to merge 3 commits into
Conversation
`lazy_split_view::outer-iterator::operator++()` now sets `trailing_empty_` for non-forward views when it lands past a delimiter before the end. Otherwise, iterating the inner range exhausts the shared base range and leaves the outer iterator comparing equal to `default_sentinel`, so a consumer incrementing it afterwards (e.g. `views::stride`, or a range-for's increment clause) would increment past the end, tripping hardening checks. Test coverage: `test_lwg_4249()` in P0896R4_views_lazy_split reproduces the issue example with `views::istream` and `views::stride`.
This comment was marked as resolved.
This comment was marked as resolved.
Stephan T. Lavavej (StephanTLavavej)
requested changes
Sep 25, 2026
P0896R4_views_lazy_split runs the strict C++20 matrix, in which views::stride (C++23) is not available. Compile the stride-based LWG-4249 test only when the feature is provided.
Drop the `views::stride` dependency and the `__cpp_lib_ranges_stride` guard so the test provides coverage in every configuration, including the strict C++20 ones. Assert `j != plain.end()` before and after iterating over `*j`, which is the exact observable that LWG-4249 changes.
zika (tycket033-tech)
requested a review
from Stephan T. Lavavej (StephanTLavavej)
September 30, 2026 02:38
This branch has not been deployed
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 #6317. Implements LWG-4249 (WP, Brno 2026-06).
For non-forward views, iterating an inner range can exhaust the shared base range,
leaving the outer iterator comparing equal to
default_sentinelwith a final incrementstill expected — the next
++(e.g. fromviews::stride) went past the end and trippedhardened checks. Per the resolution,
outer-iterator::operator++()now setstrailing_empty_in that case, so the increment hits the existing guard instead.Forward ranges are unaffected.
Testing: added
test_lwg_4249()toP0896R4_views_lazy_split, reproducing the issueexample (expected
[[1], [3]]). Verified with/MDd: it aborts onmain, passes here.AI disclosure: the changes in this PR were developed with AI assistance. I have
reviewed and verified them by running the tests locally.