public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/113500] New: Using std::format with float or double based std::chrono::time_point causes error: no match for 'operator<<'
@ 2024-01-19  7:11 Hirthammer@allterra-dno.de
  2024-01-19  7:40 ` [Bug libstdc++/113500] " redi at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Hirthammer@allterra-dno.de @ 2024-01-19  7:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113500

            Bug ID: 113500
           Summary: Using std::format with float or double based
                    std::chrono::time_point causes error: no match for
                    'operator<<'
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Hirthammer@allterra-dno.de
  Target Milestone: ---

Consider the following code snippet:

---
using Representation = double;
using Duration       = std::chrono::duration<Representation>;
using Clock          = std::chrono::system_clock;
using TimePoint      = std::chrono::time_point<Clock, Duration>;

TimePoint tp = {};

std::string time_string = std::format("{:%d.%m.%Y %H:%M:%S}", tp);
---


This results in the compile error:


---
error: no match for 'operator<<' (operand types are
'std::__cxx11::basic_ostringstream<char>' and 'const
std::chrono::time_point<std::chrono::_V2::system_clock,
std::chrono::duration<float> >')
  726 |                   __os << __t;
      |                   ~~~~~^~~~~~
---

If you change the type def `Representation` to an integer or unsigned integer
type, the code compiles.

System Info:

~~~
OS: Ubuntu 22.04 LTS
GCC-Version: 13.1.0
arguments: -std=c++20
~~~

Here is a link with the code that produces the error in Compiler Explorer:

https://godbolt.org/z/hhPrG1z37

Side note: 
Don't know if it helps, but the latest clang compiler version produces the same
error. The related bug report can be found here:

https://github.com/llvm/llvm-project/issues/78555

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-01-30 15:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19  7:11 [Bug libstdc++/113500] New: Using std::format with float or double based std::chrono::time_point causes error: no match for 'operator<<' Hirthammer@allterra-dno.de
2024-01-19  7:40 ` [Bug libstdc++/113500] " redi at gcc dot gnu.org
2024-01-19  7:45 ` redi at gcc dot gnu.org
2024-01-19  8:14 ` Hirthammer@allterra-dno.de
2024-01-19 11:49 ` redi at gcc dot gnu.org
2024-01-19 13:09 ` Hirthammer@allterra-dno.de
2024-01-19 13:39 ` redi at gcc dot gnu.org
2024-01-19 13:44 ` redi at gcc dot gnu.org
2024-01-19 21:26 ` redi at gcc dot gnu.org
2024-01-21 22:25 ` cvs-commit at gcc dot gnu.org
2024-01-21 22:27 ` redi at gcc dot gnu.org
2024-01-22  8:37 ` Hirthammer@allterra-dno.de
2024-01-30 14:55 ` cvs-commit at gcc dot gnu.org
2024-01-30 15:18 ` redi at gcc dot gnu.org

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).