Skip to content

Implement LWG-4249 The past end issue for lazy_split_view - #6463

Open
zika (tycket033-tech) wants to merge 3 commits into
microsoft:mainfrom
tycket033-tech:issue-6317-lwg-4249-lazy-split-past-end
Open

zika (tycket033-tech) wants to merge 3 commits into
microsoft:mainfrom
tycket033-tech:issue-6317-lwg-4249-lazy-split-past-end

Conversation

@tycket033-tech

@tycket033-tech zika (tycket033-tech) commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

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_sentinel with a final increment
still expected — the next ++ (e.g. from views::stride) went past the end and tripped
hardened checks. Per the resolution, outer-iterator::operator++() now sets
trailing_empty_ in that case, so the increment hits the existing guard instead.
Forward ranges are unaffected.

Testing: added test_lwg_4249() to P0896R4_views_lazy_split, reproducing the issue
example (expected [[1], [3]]). Verified with /MDd: it aborts on main, 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.

`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`.
Copilot AI balanced review requested due to automatic review settings September 25, 2026 09:34
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Sep 25, 2026
@tycket033-tech
zika (tycket033-tech) requested a review from a team as a code owner September 25, 2026 09:34
@azure-pipelines

This comment was marked as resolved.

This comment was marked as resolved.

Comment thread tests/std/tests/P0896R4_views_lazy_split/test.cpp Outdated
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added LWG Library Working Group issue ranges C++20/23 ranges labels 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.
Copilot AI review requested due to automatic review settings September 25, 2026 17:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation follows the adopted resolution and the regression test covers the reported failure.

Review effort: Balanced
Findings: None

Resolved since last review (1)

Comment thread tests/std/tests/P0896R4_views_lazy_split/test.cpp Outdated
Comment thread tests/std/tests/P0896R4_views_lazy_split/test.cpp
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.
Copilot AI review requested due to automatic review settings September 26, 2026 12:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused implementation matches the adopted resolution and is covered by a reproducing regression test.

Review effort: Balanced
Findings: None

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LWG Library Working Group issue ranges C++20/23 ranges

Projects

Status: Initial Review

Development

Successfully merging this pull request may close these issues.

LWG-4249 The past end issue for lazy_split_view

4 participants