https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116755
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:7ea30d4a5b211cc8ddda8f7f33bb2308b681be74 commit r13-9074-g7ea30d4a5b211cc8ddda8f7f33bb2308b681be74 Author: Jonathan Wakely <jwak...@redhat.com> Date: Wed Sep 18 17:20:29 2024 +0100 libstdc++: Fix formatting of most negative chrono::duration [PR116755] When formatting chrono::duration<signed-integer-type, P>::min() we were causing undefined behaviour by trying to form the negative of the most negative value. If we convert negative durations with integer rep to the corresponding unsigned integer rep then we can safely represent all values. libstdc++-v3/ChangeLog: PR libstdc++/116755 * include/bits/chrono_io.h (formatter<duration<R,P>>::format): Cast negative integral durations to unsigned rep. * testsuite/20_util/duration/io.cc: Test the most negative integer durations. (cherry picked from commit 482e651f5750e4648ade90e32ed45b094538e7f8)