From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F278E3858D35; Mon, 8 May 2023 15:18:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F278E3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683559082; bh=xQmYdxj/J0eNy3jslsK0bfdjNdQXUCtioQIVo09ejo8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m4iz4GTS7MlBivIho4eTP1MnQXCAETv7J0nUL2X3r6VlH3OgnYBGXbfNYMX7A6hNR uZVXl07SFCAUvCJF41fS9Ng30mYB6c956TWulKFSxOHDy7PyMgTuXWo1d9tNnghotX J7SnhfMfw2SyKzTcYQiQJ0hI3j14R5jKwYqBYnWY= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109772] Memory layout optimization of std::chrono::hh_mm_ss is wrong Date: Mon, 08 May 2023 15:18:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: ABI X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109772 --- Comment #1 from Jonathan Wakely --- I had a brain fart with this constraint for choosing the subseconds representation: // True if the maximum constructor argument can be represented in _= Tp. template static constexpr bool __fits =3D duration_values::max() <=3D duration_values<_Tp>::max(); What matters is not the _Duration type, but the precision type. Given a _Duration like duration> we can easily fit the maxi= mum fractional seconds value of 1023 in a 32-bit integer. But what we actually = need to store is not a count of 1023 [1/1024]s units, but 9990234375 [1/10000000000]s units. And 9990234375 doesn't fit in 32 bits.=