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++/115668] New: Cannot format chrono::duration<unsigned> Date: Wed, 26 Jun 2024 17:23:58 +0000 [thread overview] Message-ID: <bug-115668-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115668 Bug ID: 115668 Summary: Cannot format chrono::duration<unsigned> Product: gcc Version: 13.3.1 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- std::format("", std::chrono::duration<unsigned>{}) fails with: /home/jwakely/gcc/15/include/c++/15.0.0/bits/chrono_io.h:1699:44: error: no matching function for call to ‘abs(const std::chrono::duration<unsigned int>&)’ 1699 | return _M_f._M_format(chrono::abs(__d), __fc, __d < __d.zero()); | ~~~~~~~~~~~^~~~~ chrono::abs is only defined for durations with signed rep types. This fixes it: --- a/libstdc++-v3/include/bits/chrono_io.h +++ b/libstdc++-v3/include/bits/chrono_io.h @@ -1696,10 +1696,10 @@ namespace __format format(const chrono::duration<_Rep, _Period>& __d, basic_format_context<_Out, _CharT>& __fc) const { - const bool __is_neg = __d < __d.zero(); - if (__is_neg) - __d = -__d; - return _M_f._M_format(__d, __fc, __is_neg); + if (__d < __d.zero()) + return _M_f._M_format(-__d, __fc, true); + else + return _M_f._M_format(__d, __fc, false); } private:
next reply other threads:[~2024-06-26 17:23 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-06-26 17:23 redi at gcc dot gnu.org [this message] 2024-06-26 17:30 ` [Bug libstdc++/115668] " redi at gcc dot gnu.org 2024-06-26 17:31 ` redi at gcc dot gnu.org 2024-06-27 8:48 ` cvs-commit at gcc dot gnu.org 2024-06-28 19:39 ` cvs-commit at gcc dot gnu.org 2024-06-28 19:39 ` cvs-commit at gcc dot gnu.org 2024-06-28 19:40 ` redi 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-115668-4@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).