]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix std::format for chrono::duration with unsigned rep [PR115668]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 26 Jun 2024 19:22:54 +0000 (20:22 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 27 Jun 2024 08:39:41 +0000 (09:39 +0100)
commitdafa750c8a6f0a088677871bfaad054881737ab1
tree4e27b9cf146ddf3890b1a2b09d2589d743a9933f
parent8fd84bc009b3073666a24047c78a04c19eeab752
libstdc++: Fix std::format for chrono::duration with unsigned rep [PR115668]

Using std::chrono::abs is only valid if numeric_limits<rep>::is_signed
is true, so using it unconditionally made it ill-formed to format a
duration with an unsigned rep.

The duration formatter might as negate the duration itself instead of
using chrono::abs, because it already needs to check for a negative
value.

libstdc++-v3/ChangeLog:

PR libstdc++/115668
* include/bits/chrono_io.h (formatter<duration<R,P, C>::format):
Do not use chrono::abs.
* testsuite/20_util/duration/io.cc: Check formatting a duration
with unsigned rep.
libstdc++-v3/include/bits/chrono_io.h
libstdc++-v3/testsuite/20_util/duration/io.cc
This page took 0.058946 seconds and 6 git commands to generate.