This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

3231. year_month_day_last::day specification does not cover !ok() values

Section: [] Status: C++20 Submitter: Tomasz Kamiński Opened: 2019-06-29 Last modified: 2021-02-25

Priority: 0

View all issues with C++20 status.


The current specification of the year_month_day_last::day function does not cover the behaviour in the situation when year_month_day_last value is not ok(). To illustrate the sentence from [] p13:

A day representing the last day of the (year, month) pair represented by *this.

is unclear in the situation when month member has !ok value, e.g. what is last day of 14th month of 2019.

The proposed resolution makes the value of (and by consequence conversion to sys_days/local_days) unspecified if ymdl.ok() is false. This make is consistent with rest of the library, that produces unspecified values in similiar situation, e.g.: [] p18, [] p19, [] p14.

[2019-07 Issue Prioritization]

Status to Tentatively Ready after five positive votes on the reflector.

Proposed resolution:

This wording is relative to N4820.

  1. Modify [] as indicated:

    constexpr chrono::day day() const noexcept;

    -13- Returns: If ok() is true, returns aA day representing the last day of the (year, month) pair represented by *this. Otherwise the returned value is unspecified.

    -14- [Note: This value may be computed on demand. — end note]