From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EAA783858C56; Fri, 19 Jan 2024 13:39:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAA783858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705671571; bh=S8ZimRkQTGD4XQk5IVIi4b+Z7eUuqQsBrSQhFYAxIcM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dwybGjLaYzIFxjGzQtUBQvfzi8LZihAlscqrjCwrfS/kI2Ur0t5enfrRCcZw1GYE4 UJ2MIbIpV+a9YISFF/gOwnuoa/CaJ57EorhFjdSlQP/lL9RSmW92KIUH11owG3rd38 n0nQkIHOJgydRrYcOQGWUjS6BYrDERyLmYxVFXXc= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113500] Using std::format with float or double based std::chrono::time_point causes error: no match for 'operator<<' Date: Fri, 19 Jan 2024 13:39:31 +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: 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.3 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=3D113500 --- Comment #6 from Jonathan Wakely --- (In reply to Hirthammer from comment #5) > This whole thing with std::format and std::chrono::time_point is currentl= y a > total minefield. That seems like an exaggeration. > In MSVC it is even more complicated and I already reported > the bug in October 2023. See: >=20 > https://developercommunity.visualstudio.com/t/Using-std::format-with- > unsigned-integer-/10501153 >=20 > If you change the clock to utc_clock or gps_clock the code compiles with > MSVC (but not with GCC) on Compiler Explorer. It compiles fine with GCC for me. > I don't know much about the exact definitions of the standard. But I find= it > very confusing if std::format generally supports a std::chrono::time_point > as an input, but depending on the chosen template arguments of the > time_point it does or does not compile. That's because operator<< is not defined in general for time_point, only for specific clocks. It's defined for utc_time and gps_time unconditionally. It= 's only defined for sys_time for non-floating-point representations and periods less than a day: https://en.cppreference.com/w/cpp/chrono/system_clock/operator_ltlt Because std::format for chrono types is specified to use operator<< in some cases, that constraint for sys_time also affects std::format.=