[libcxx-commits] [PATCH] D124175: [libcxx] Reject month 0 in get_date/__get_month
David Spickett via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 22 02:19:00 PDT 2022
DavidSpickett added a comment.
> Nothing wrong with cppreference, but for the Standard wording we usually use http://eel.is/c++draft/locale.time.get.virtuals#lib:do_get_date,time_get. (Not sure whether you know this resource.)
I didn't, that's much better since cppreference has some of the descriptions merged.
> I think libstdc++'s behaviour is the correct behaviour. But fixing that should be a separate review.
I think I see the logic there now. For MM/DD/YYYY "13/01/2022", the "1" could be part of a valid date ("1/01/2022"), but "13" could not. For the "00/" case, you can have one leading zero so "0" could possibly be part of a valid date ("01/01/2022") but "00" cannot be.
================
Comment at: libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp:114
+ // We consume the first two chars checking the month.
+ assert(base(i) == in+2);
+ // tm is not modified.
----------------
Mordante wrote:
> This should be guarded with
> ```
> #if _LIBCPP_VERSION
> assert(base(i) == in+2);
> #else
> assert(base(i) == in+2);
> #endif
> ```
> Our tests should be portable and MSVC STL and GCC use them.
I'll confirm what MSVC does and add these guards.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124175/new/
https://reviews.llvm.org/D124175
More information about the libcxx-commits
mailing list