public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-109772-4-jeVgzYLYYn@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109772-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109772 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- 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<typename _Tp> static constexpr bool __fits = duration_values<typename _Duration::rep>::max() <= duration_values<_Tp>::max(); What matters is not the _Duration type, but the precision type. Given a _Duration like duration<int64_t, ratio<1, 1024>> we can easily fit the maximum 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.
next prev parent reply other threads:[~2023-05-08 15:18 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-08 14:41 [Bug libstdc++/109772] New: " redi at gcc dot gnu.org 2023-05-08 14:41 ` [Bug libstdc++/109772] " redi at gcc dot gnu.org 2023-05-08 15:18 ` redi at gcc dot gnu.org [this message] 2023-05-08 15:59 ` redi at gcc dot gnu.org 2023-05-08 16:32 ` redi at gcc dot gnu.org 2023-05-10 22:47 ` [Bug libstdc++/109772] [13/14 Regression] " redi at gcc dot gnu.org 2023-05-11 20:19 ` cvs-commit at gcc dot gnu.org 2023-07-27 9:26 ` [Bug libstdc++/109772] [13 " rguenth at gcc dot gnu.org 2024-05-13 11:34 ` rguenth at gcc dot gnu.org 2024-05-21 9:15 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-109772-4-jeVgzYLYYn@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).