From e25a2601aaa95c861af3228982ecbb2b1c19d27a Mon Sep 17 00:00:00 2001 From: Marek Kurdej Date: Wed, 13 May 2020 11:37:58 +0200 Subject: [PATCH] [libc++] [LWG3321] Mark "year_month_day_last::day() specification does not cover !ok() values" issue as "Nothing to do", but add assertion. Summary: This LWG issue states that the result of `year_month_day_last::day()` is implementation defined if `ok()` is `false`. However, from user perspective, calling `day()` in this situation will lead to a (possibly difficult to find) crash. Hence, I have added an assertion to warn user at least when assertions are enabled. I am however not aware of the libc++ stand on the desired behaviour. Reviewers: ldionne, mclow.lists, EricWF, #libc Reviewed By: ldionne, #libc Subscribers: christof, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D70346 --- libcxx/include/chrono | 2 ++ libcxx/www/cxx2a_status.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libcxx/include/chrono b/libcxx/include/chrono index 6e5de39..9913dc1 100644 --- a/libcxx/include/chrono +++ b/libcxx/include/chrono @@ -824,6 +824,7 @@ constexpr chrono::year operator ""y(unsigned lo */ #include <__config> +#include <__debug> #include #include #include @@ -2454,6 +2455,7 @@ chrono::day year_month_day_last::day() const noexcept chrono::day(31), chrono::day(31), chrono::day(30), chrono::day(31), chrono::day(30), chrono::day(31) }; + _LIBCPP_ASSERT(ok(), "year_month_day_last::day(): year_month_day_last is invalid"); return month() != February || !__y.is_leap() ? __d[static_cast(month()) - 1] : chrono::day{29}; } diff --git a/libcxx/www/cxx2a_status.html b/libcxx/www/cxx2a_status.html index 4b715e7..bee06e6 100644 --- a/libcxx/www/cxx2a_status.html +++ b/libcxx/www/cxx2a_status.html @@ -439,7 +439,7 @@ 3209Expression in year::ok() returns clause is ill-formedCologneComplete - 3231year_month_day_last::day specification does not cover !ok() valuesBelfast + 3231year_month_day_last::day specification does not cover !ok() valuesBelfastNothing to do 3225zoned_time converting constructor shall not be noexceptBelfast 3190std::allocator::allocate sometimes returns too little storageBelfast 3218Modifier for %d parse flag does not match POSIX and format specificationBelfast -- 2.7.4