[all-commits] [llvm/llvm-project] ab07d0: [libcxx] Reject month 0 in get_date/__get_month

David Spickett via All-commits all-commits at lists.llvm.org
Fri May 6 03:08:06 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ab07d06e7b864029620927790dfb23b6a5900e13
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2022-05-06 (Fri, 06 May 2022)

  Changed paths:
    M libcxx/include/locale
    M libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp

  Log Message:
  [libcxx] Reject month 0 in get_date/__get_month

[libcxx] Reject month 0 in get_date/__get_month

This fixes #47663.

Months in dates should be >= 1 and <= 12.
We parse up to two digits then minus one, because
we want to store this as "months since January"

However we didn't check that the result of that
was not -1. For example if you had (MM/DD/YYYY)

Added tests for:
* Failing if month is 0
* Failing if month is 13
* Allowing a leading zero in month e.g. "01"

Note that libc++ and libstdc++ return different
values on parsing failure, and MSVC STL returns
end of stream instead.

Handle the first two by checking for defines, MSVC STL
expects these tests to fail for other reasons already:
so not handling that case here.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D124175

More information about the All-commits mailing list