Skip to content

Commit f909dd7

Browse files
committed
New issue from Jan Schultke: "front() and back() are not hardened for zero-length std::arrays"
1 parent 5bd2e98 commit f909dd7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

xml/issue4276.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4276" status="New">
5+
<title>`front()` and `back()` are not hardened for zero-length `std::array`s</title>
6+
<section>
7+
<sref ref="[array.zero]"/>
8+
</section>
9+
<submitter>Jan Schultke</submitter>
10+
<date>08 Jun 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
The intent of <paper num="P3471"/> "Standard library hardening" is clearly to provide hardened preconditions
16+
for members of sequence containers, including `std::array`. However, a zero-length `std::array` dodges this
17+
hardening by having undefined behavior for `front()` and `back()` explicitly specified in
18+
<sref ref="[array.zero]"/> paragraph 3.
19+
<p/>
20+
Without this paragraph, `front()` and `back()` would be hardened as well, as specified in <sref ref="[sequence.reqmts]"/>.
21+
</p>
22+
</discussion>
23+
24+
<resolution>
25+
<p>
26+
This wording is relative to <paper num="N5008"/>.
27+
</p>
28+
29+
<ol>
30+
<li><p>Modify <sref ref="[array.zero]"/> as indicated:</p>
31+
32+
<blockquote>
33+
<p>
34+
<del>-3- The effect of calling `front()` or `back()` for a zero-sized array is undefined.</del>
35+
</p>
36+
</blockquote>
37+
</li>
38+
39+
</ol>
40+
</resolution>
41+
42+
</issue>

0 commit comments

Comments
 (0)