This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
front()
and back()
are not hardened for zero-length std::array
sSection: 23.3.3.5 [array.zero] Status: New Submitter: Jan Schultke Opened: 2025-06-08 Last modified: 2025-06-14
Priority: Not Prioritized
View other active issues in [array.zero].
View all other issues in [array.zero].
View all issues with New status.
Discussion:
The intent of P3471 "Standard library hardening" is clearly to provide hardened preconditions
for members of sequence containers, including std::array
. However, a zero-length std::array
dodges this
hardening by having undefined behavior for front()
and back()
explicitly specified in
23.3.3.5 [array.zero] paragraph 3.
front()
and back()
would be hardened as well, as specified in 23.2.4 [sequence.reqmts].
Proposed resolution:
This wording is relative to N5008.
Modify 23.3.3.5 [array.zero] as indicated:
-3- The effect of callingfront()
orback()
for a zero-sized array is undefined.