Skip to content

Commit a723d6c

Browse files
author
github-actions
committed
Automatic update from GitHub Actions workflow
1 parent 2e81805 commit a723d6c

26 files changed

+760
-44
lines changed

issue3181.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ <h3 id="3181"><a href="lwg-closed.html#3181">3181</a>. <code>split_view::outer_i
6767
<b>Submitter:</b> Casey Carter <b>Opened:</b> 2019-01-05 <b>Last modified:</b> 2023-02-07</p>
6868
<p><b>Priority: </b>Not Prioritized
6969
</p>
70+
<p><b>View other</b> <a href="lwg-index-open.html#range.lazy.split.outer">active issues</a> in [range.lazy.split.outer].</p>
7071
<p><b>View all other</b> <a href="lwg-index.html#range.lazy.split.outer">issues</a> in [range.lazy.split.outer].</p>
7172
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
7273
<p><b>Discussion:</b></p>

issue3505.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ <h3 id="3505"><a href="lwg-defects.html#3505">3505</a>. <code>split_view::<i>out
6767
<b>Submitter:</b> Tim Song <b>Opened:</b> 2020-11-20 <b>Last modified:</b> 2023-11-22</p>
6868
<p><b>Priority: </b>2
6969
</p>
70+
<p><b>View other</b> <a href="lwg-index-open.html#range.lazy.split.outer">active issues</a> in [range.lazy.split.outer].</p>
7071
<p><b>View all other</b> <a href="lwg-index.html#range.lazy.split.outer">issues</a> in [range.lazy.split.outer].</p>
7172
<p><b>View all issues with</b> <a href="lwg-status.html#C++23">C++23</a> status.</p>
7273
<p><b>Discussion:</b></p>

issue3686.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ <h3 id="3686"><a href="lwg-active.html#3686">3686</a>. In <code>lazy_split_view<
7070
<b>Submitter:</b> Konstantin Varlamov <b>Opened:</b> 2022-03-23 <b>Last modified:</b> 2022-05-17</p>
7171
<p><b>Priority: </b>3
7272
</p>
73+
<p><b>View other</b> <a href="lwg-index-open.html#range.lazy.split.outer">active issues</a> in [range.lazy.split.outer].</p>
7374
<p><b>View all other</b> <a href="lwg-index.html#range.lazy.split.outer">issues</a> in [range.lazy.split.outer].</p>
7475
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
7576
<p><b>Discussion:</b></p>

issue3904.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ <h3 id="3904"><a href="lwg-defects.html#3904">3904</a>. <code>lazy_split_view::<
6767
<b>Submitter:</b> Patrick Palka <b>Opened:</b> 2023-03-13 <b>Last modified:</b> 2023-11-22</p>
6868
<p><b>Priority: </b>Not Prioritized
6969
</p>
70+
<p><b>View other</b> <a href="lwg-index-open.html#range.lazy.split.outer">active issues</a> in [range.lazy.split.outer].</p>
7071
<p><b>View all other</b> <a href="lwg-index.html#range.lazy.split.outer">issues</a> in [range.lazy.split.outer].</p>
7172
<p><b>View all issues with</b> <a href="lwg-status.html#WP">WP</a> status.</p>
7273
<p><b>Discussion:</b></p>

issue4249.html

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Issue 4249: The past end issue for lazy_split_view</title>
6+
<meta property="og:title" content="Issue 4249: The past end issue for lazy_split_view">
7+
<meta property="og:description" content="C++ library issue. Status: New">
8+
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4249.html">
9+
<meta property="og:type" content="website">
10+
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
11+
<meta property="og:image:alt" content="C++ logo">
12+
<style>
13+
p {text-align:justify}
14+
li {text-align:justify}
15+
pre code.backtick::before { content: "`" }
16+
pre code.backtick::after { content: "`" }
17+
blockquote.note
18+
{
19+
background-color:#E0E0E0;
20+
padding-left: 15px;
21+
padding-right: 15px;
22+
padding-top: 1px;
23+
padding-bottom: 1px;
24+
}
25+
ins {background-color:#A0FFA0}
26+
del {background-color:#FFA0A0}
27+
table.issues-index { border: 1px solid; border-collapse: collapse; }
28+
table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
29+
table.issues-index td { padding: 4px; border: 1px solid; }
30+
table.issues-index td:nth-child(1) { text-align: right; }
31+
table.issues-index td:nth-child(2) { text-align: left; }
32+
table.issues-index td:nth-child(3) { text-align: left; }
33+
table.issues-index td:nth-child(4) { text-align: left; }
34+
table.issues-index td:nth-child(5) { text-align: center; }
35+
table.issues-index td:nth-child(6) { text-align: center; }
36+
table.issues-index td:nth-child(7) { text-align: left; }
37+
table.issues-index td:nth-child(5) span.no-pr { color: red; }
38+
@media (prefers-color-scheme: dark) {
39+
html {
40+
color: #ddd;
41+
background-color: black;
42+
}
43+
ins {
44+
background-color: #225522
45+
}
46+
del {
47+
background-color: #662222
48+
}
49+
a {
50+
color: #6af
51+
}
52+
a:visited {
53+
color: #6af
54+
}
55+
blockquote.note
56+
{
57+
background-color: rgba(255, 255, 255, .10)
58+
}
59+
}
60+
</style>
61+
</head>
62+
<body>
63+
<hr>
64+
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p>
65+
<h3 id="4249"><a href="lwg-active.html#4249">4249</a>. The past end issue for <code class='backtick'>lazy_split_view</code></h3>
66+
<p><b>Section:</b> 25.7.16.3 <a href="https://wg21.link/range.lazy.split.outer">[range.lazy.split.outer]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
67+
<b>Submitter:</b> Hewill Kang <b>Opened:</b> 2025-04-26 <b>Last modified:</b> 2025-04-27</p>
68+
<p><b>Priority: </b>Not Prioritized
69+
</p>
70+
<p><b>View other</b> <a href="lwg-index-open.html#range.lazy.split.outer">active issues</a> in [range.lazy.split.outer].</p>
71+
<p><b>View all other</b> <a href="lwg-index.html#range.lazy.split.outer">issues</a> in [range.lazy.split.outer].</p>
72+
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
73+
<p><b>Discussion:</b></p>
74+
<p>
75+
Consider (<a href="https://godbolt.org/z/eeMe8aTqv">demo</a>):
76+
</p>
77+
<blockquote><pre>
78+
#include &lt;print&gt;
79+
#include &lt;ranges&gt;
80+
#include &lt;sstream&gt;
81+
82+
int main() {
83+
std::istringstream is{"1 0 2 0 3"};
84+
auto r = std::views::istream&lt;int&gt;(is)
85+
| std::views::lazy_split(0)
86+
| std::views::stride(2);
87+
std::println("{}", r); // should print [[1], [3]]
88+
}
89+
</pre></blockquote>
90+
<p>
91+
The above leads to SIGSEGV in libstdc++, the reason is that we are iterating over the nested
92+
range as:
93+
</p>
94+
<blockquote><pre>
95+
for (auto&amp;&amp; inner : r) {
96+
for (auto&amp;&amp; elem : inner) {
97+
// [&hellip;]
98+
}
99+
}
100+
</pre></blockquote>
101+
<p>
102+
which is disassembled as:
103+
</p>
104+
<blockquote><pre>
105+
auto outer_it = r.begin();
106+
std::default_sentinel_t out_end = r.end();
107+
for(; outer_it != out_end; ++outer_it) {
108+
auto&amp;&amp; inner_r = *outer_it;
109+
auto inner_it = inner_r.begin();
110+
std::default_sentinel_t inner_end = inner_r.end();
111+
for(; inner_it != inner_end; ++inner_it) {
112+
auto&amp;&amp; elem = *inner_it;
113+
// [&hellip;]
114+
}
115+
}
116+
</pre></blockquote>
117+
<p>
118+
Since <code class='backtick'>inner_it</code> and <code class='backtick'>output_it</code> actually update the same iterator,
119+
when we back to the outer loop, <code>lazy_split_view::<i>outer-iterator</i></code>
120+
is now equal to <code class='backtick'>default_sentinel</code>, which makes <code class='backtick'>output_it</code> reach the end,
121+
so <code class='backtick'>++outer_it</code> will increment the iterator past end, triggering the assertion.
122+
</p>
123+
<p>
124+
Note that this <a href="https://godbolt.org/z/6Tx61eeq8">also happens</a> in MSVC-STL
125+
when <code class='backtick'>_ITERATOR_DEBUG_LEVEL</code> is turned on.
126+
</p>
127+
<p>
128+
It seems that extra flags are needed to fix this issue because <code class='backtick'>output_it</code> should not
129+
be considered to reach the end when we back to the outer loop.
130+
</p>
131+
132+
133+
<p id="res-4249"><b>Proposed resolution:</b></p>
134+
<p>
135+
This wording is relative to <a href="https://wg21.link/N5008">N5008</a>.
136+
</p>
137+
138+
<ol>
139+
140+
<li><p>Modify 25.7.16.3 <a href="https://wg21.link/range.lazy.split.outer">[range.lazy.split.outer]</a> as indicated:</p>
141+
142+
<blockquote>
143+
<blockquote>
144+
<pre>
145+
namespace std::ranges {
146+
template&lt;input_range V, forward_range Pattern&gt;
147+
requires view&lt;V&gt; &amp;&amp; view&lt;Pattern&gt; &amp;&amp;
148+
indirectly_comparable&lt;iterator_t&lt;V&gt;, iterator_t&lt;Pattern&gt;, ranges::equal_to&gt; &amp;&amp;
149+
(forward_range&lt;V&gt; || <i>tiny-range</i>&lt;Pattern&gt;)
150+
template&lt;bool Const&gt;
151+
struct lazy_split_view&lt;V, Pattern&gt;::<i>outer-iterator</i> {
152+
private:
153+
using <i>Parent</i> = <i>maybe-const</i>&lt;Const, lazy_split_view&gt;; // <i>exposition only</i>
154+
using <i>Base</i> = <i>maybe-const</i>&lt;Const, V&gt;; // <i>exposition only</i>
155+
<i>Parent</i>* <i>parent_</i> = nullptr; // <i>exposition only</i>
156+
157+
iterator_t&lt;<i>Base</i>&gt; <i>current_</i> = iterator_t&lt;<i>Base</i>&gt;(); // <i>exposition only, present only</i>
158+
// <i>if V models forward_range</i>
159+
160+
bool <i>trailing_empty_</i> = false; // <i>exposition only</i>
161+
<ins>bool <i>has_next_</i> = false; // <i>exposition only, present only</i></ins>
162+
<ins>// <i>if forward_range&lt;<i>V</i>&gt; is false</i></ins>
163+
public:
164+
[&hellip;]
165+
};
166+
}
167+
</pre>
168+
</blockquote>
169+
[&hellip;]
170+
<pre>
171+
constexpr explicit <i>outer-iterator</i>(<i>Parent</i>&amp; parent)
172+
requires (!forward_range&lt;<i>Base</i>&gt;);
173+
</pre>
174+
<blockquote>
175+
<p>
176+
-2- <i>Effects:</i> Initializes <code><i>parent_</i></code> with <code class='backtick'>addressof(parent)</code> <ins>and
177+
<code><i>has_next_</i></code> with <code><i>current</i> != ranges::end(<i>parent_</i>-&gt;<i>base_</i>)</code></ins>.
178+
</p>
179+
</blockquote>
180+
[&hellip;]
181+
<pre>
182+
constexpr <i>outer-iterator</i>&amp; operator++();
183+
</pre>
184+
<blockquote>
185+
<p>
186+
-6- <i>Effects:</i> Equivalent to:
187+
</p>
188+
<blockquote><pre>
189+
const auto end = ranges::end(<i>parent_</i>-&gt;<i>base_</i>);
190+
if (<i>current</i> == end) {
191+
<i>trailing_empty_</i> = false;
192+
<ins>if constexpr (!forward_range&lt;V&gt;)
193+
<i>has_next_</i> = false;</ins>
194+
return <code>*this</code>;
195+
}
196+
const auto [pbegin, pend] = subrange{<i>parent_</i>-&gt;<i>pattern_</i>};
197+
if (pbegin == pend) ++<i>current</i>;
198+
else if constexpr (<i>tiny-range</i>&lt;Pattern&gt;) {
199+
<i>current</i> = ranges::find(std::move(<i>current</i>), end, *pbegin);
200+
if (<i>current</i> != end) {
201+
++<i>current</i>;
202+
if (<i>current</i> == end)
203+
<i>trailing_empty_</i> = true;
204+
}
205+
}
206+
else {
207+
do {
208+
auto [b, p] = ranges::mismatch(<i>current</i>, end, pbegin, pend);
209+
if (p == pend) {
210+
<i>current</i> = b;
211+
if (<i>current</i> == end)
212+
<i>trailing_empty_</i> = true;
213+
break; <i>// The pattern matched; skip it</i>
214+
}
215+
} while (++<i>current</i> != end);
216+
}
217+
<ins>if constexpr (!forward_range&lt;V&gt;)
218+
if (<i>current</i> == end)
219+
<i>has_next_</i> = false;</ins>
220+
return *this;
221+
</pre></blockquote>
222+
</blockquote>
223+
[&hellip;]
224+
<pre>
225+
friend constexpr bool operator==(const <i>outer-iterator</i>&amp; x, default_sentinel_t);
226+
</pre>
227+
<blockquote>
228+
<p>
229+
-8- <i>Effects:</i> Equivalent to:
230+
</p>
231+
<blockquote><pre>
232+
<ins>if constexpr (!forward_range&lt;V&gt;)
233+
return !x.<i>has_next_</i> &amp;&amp; !x.<i>trailing_empty_</i>;
234+
else</ins>
235+
return x.<i>current</i> == ranges::end(x.<i>parent_</i>-&gt;<i>base_</i>) &amp;&amp; !x.<i>trailing_empty_</i>;
236+
</pre></blockquote>
237+
</blockquote>
238+
</blockquote>
239+
240+
</li>
241+
242+
</ol>
243+
244+
245+
246+
247+
248+
</body>
249+
</html>

0 commit comments

Comments
 (0)