https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116755
--- Comment #15 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:aeb54d0f3a9eb9363157a040beaddd4939bd4774 commit r14-10732-gaeb54d0f3a9eb9363157a040beaddd4939bd4774 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)