Title
`front()` and `back()` are not hardened for zero-length `std::array`s
Status
new
Section
[array.zero]
Submitter
Jan Schultke

Created on 2025-06-08.00:00:00 last changed 2 weeks ago

Messages

Date: 2025-06-14.10:24:43

Proposed resolution:

This wording is relative to N5008.

  1. Modify [array.zero] as indicated:

    -3- The effect of calling `front()` or `back()` for a zero-sized array is undefined.

Date: 2025-06-08.00:00:00

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 [array.zero] paragraph 3.

Without this paragraph, `front()` and `back()` would be hardened as well, as specified in [sequence.reqmts].

History
Date User Action Args
2025-06-14 10:24:43adminsetmessages: + msg14828
2025-06-08 00:00:00admincreate