This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
front() and back() are not hardened for zero-length std::arraysSection: 23.3.3.5 [array.zero] Status: WP Submitter: Jan Schultke Opened: 2025-06-08 Last modified: 2025-11-11
Priority: Not Prioritized
View all other issues in [array.zero].
View all issues with WP 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].
[2025-08-21; Reflector poll]
Set status to Tentatively Ready after eight votes in favour during reflector poll.
[Kona 2025-11-08; Status changed: Voting → WP.]
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.