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

Created on 2025-06-08.00:00:00 last changed 1 week ago

Messages

Date: 2025-11-11.10:48:16

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-11-11.10:48:16

[ Kona 2025-11-08; Status changed: Voting → WP. ]

Date: 2025-08-15.00:00:00

[ 2025-08-21; Reflector poll ]

Set status to Tentatively Ready after eight votes in favour during reflector poll.

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-11-11 10:48:16adminsetmessages: + msg15626
2025-11-11 10:48:16adminsetstatus: voting -> wp
2025-10-30 17:45:31adminsetstatus: ready -> voting
2025-08-26 14:53:08adminsetmessages: + msg14960
2025-08-26 14:53:08adminsetstatus: new -> ready
2025-06-14 10:24:43adminsetmessages: + msg14828
2025-06-08 00:00:00admincreate