[libcxx-commits] [PATCH] D155504: [libc++][chrono] Fixes month inc and dec operations.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jul 17 11:41:05 PDT 2023
Mordante created this revision.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
The operator++, operator++(int), operator--, and operator--(int) need to
change the month to a valid value. The wording is specified in terms of
operator+(const month& x, const months& y) noexcept;
which has the correct behavior. The aforementioned operators instead
used ++/-- on the internal value direction, resulting in incorrect
behaviour.
As a drive-by improve the unit tests:
- use the typical constexpr test method
- test whether the month is valid after the operations
- format the tests
Fixes: https://llvm.org/PR63912
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155504
Files:
libcxx/include/__chrono/month.h
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/decrement.pass.cpp
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/increment.pass.cpp
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.members/plus_minus_equal.pass.cpp
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.nonmembers/minus.pass.cpp
libcxx/test/std/time/time.cal/time.cal.month/time.cal.month.nonmembers/plus.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155504.541161.patch
Type: text/x-patch
Size: 12657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230717/3e9ef46e/attachment.bin>
More information about the libcxx-commits
mailing list