]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix std::format output of %C for negative years
authorJonathan Wakely <jwakely@redhat.com>
Mon, 11 Dec 2023 15:33:59 +0000 (15:33 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 13 Dec 2023 09:20:27 +0000 (09:20 +0000)
commit1a0aafdc2cf94c53e6451ac76fbc875cb56408df
treef9f3e867ee16fffcd4bfd7c7d2093f37de14e8f3
parentf5951e7a770aa6abbfc0136e08cd3822528f0efe
libstdc++: Fix std::format output of %C for negative years

During discussion of LWG 4022 I noticed that we do not correctly
implement floored division for the century. We were just truncating
towards zero, rather than applying the floor function. For negative
values that rounds the wrong way.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_C_y_Y): Fix
rounding for negative centuries.
* testsuite/std/time/year/io.cc: Check %C for negative years.

(cherry picked from commit a01462ae8bafa86e7df47a252917ba6899d587cf)
libstdc++-v3/include/bits/chrono_io.h
libstdc++-v3/testsuite/std/time/year/io.cc