Bug#1087630: libstdc++-12-dev: std::chrono::milliseconds template class Rep overflows signed integer type
Package: libstdc++-12-dev
Version: 12.2.0-14+rpi1
Severity: normal
X-Debbugs-Cc: software@quantentunnel.de
Dear Maintainer,
I use std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds> and the g++ compiler with -std=c++17.
When I calculate the difference between two timepoints (i.e., a duration in std::chrono::milliseconds)
and print the tick count obtained from count() using std::ostream and operator<<,
then the difference is printed as a negative number when it should be a (large) positive number.
Maybe the problem is in /usr/include/c++/12/bits/chrono.h where the definition of _GLIBCXX_CHRONO_INT64_T mixes signed and unsigned integers:
"static_assert(std::numeric_limits<unsigned long long>::digits >= 64,...)" checks that an unsigned integer is sufficiently large,
while "# define _GLIBCXX_CHRONO_INT64_T long long" omits signed or unsigned which defaults to my knowledge to signed.
E.g., std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds>::max() minus ...::min() prints a tick count of -1 which supports
that it should be max UINT64.
-- System Information:
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
Architecture: armv7l
Kernel: Linux 6.6.31+rpt-rpi-v7 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_CRAP
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages libstdc++-12-dev depends on:
ii gcc-12-base 12.2.0-14+rpi1
ii libc6-dev 2.36-9+rpt2+deb12u7
ii libgcc-12-dev 12.2.0-14+rpi1
ii libstdc++6 12.2.0-14+rpi1
libstdc++-12-dev recommends no packages.
Versions of packages libstdc++-12-dev suggests:
pn libstdc++-12-doc <none>
-- no debconf information
Reply to: