gcc/libstdc++-v3
Jonathan Wakely 7431fcea6b libstdc++: Fix std::format for floating-point chrono::time_point [PR113500]
Currently trying to use std::format with certain specializations of
std::chrono::time_point is ill-formed, due to one member function of the
__formatter_chrono type which tries to write a time_point to an ostream.
For sys_time<floating-point> or sys_time with a period greater than days
there is no operator<< that can be used.

That operator<< is only needed when using an empty chrono-specs in the
format string, like "{}", but the ill-formed expression gives an error
even if not actually used. This means it's not possible to format some
other specializations of chrono::time_point, even when using a non-empty
chrono-specs.

This fixes it by avoiding using 'os << t' for all chrono::time_point
specializations, and instead using std::format("{:L%F %T}", t). So that
we continue to reject std::format("{}", sys_time{1.0s}) a check for
empty chrono-specs is added to the formatter<sys_time<D>, C>
specialization.

While testing this I noticed that the output for %S with a
floating-point duration was incorrect, as the subseconds part was being
appended to the seconds without a decimal point, and without the correct
number of leading zeros.

libstdc++-v3/ChangeLog:

	PR libstdc++/113500
	* include/bits/chrono_io.h (__formatter_chrono::_M_S): Fix
	printing of subseconds with floating-point rep.
	(__formatter_chrono::_M_format_to_ostream): Do not write
	time_point specializations directly to the ostream.
	(formatter<chrono::sys_time<D>, C>::parse): Do not allow an
	empty chrono-spec if the type fails to meet the constraints for
	writing to an ostream with operator<<.
	* testsuite/std/time/clock/file/io.cc: Check formatting
	non-integral times with empty chrono-specs.
	* testsuite/std/time/clock/gps/io.cc: Likewise.
	* testsuite/std/time/clock/utc/io.cc: Likewise.
	* testsuite/std/time/hh_mm_ss/io.cc: Likewise.
2024-01-21 22:15:06 +00:00
..
config Update copyright years. 2024-01-03 12:19:35 +01:00
doc libstdc++: Fix spelling mistake in new doc addition 2024-01-11 21:24:37 +00:00
include libstdc++: Fix std::format for floating-point chrono::time_point [PR113500] 2024-01-21 22:15:06 +00:00
libsupc++ libstdc++: use updated type for __unexpected_handler 2024-01-11 19:11:45 +00:00
po Update copyright years. 2024-01-03 12:19:35 +01:00
python libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] 2024-01-17 11:49:11 +00:00
scripts libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] 2024-01-17 11:49:11 +00:00
src libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] 2024-01-17 11:49:11 +00:00
testsuite libstdc++: Fix std::format for floating-point chrono::time_point [PR113500] 2024-01-21 22:15:06 +00:00
acinclude.m4 libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] 2024-01-17 11:49:11 +00:00
aclocal.m4
ChangeLog Daily bump. 2024-01-21 00:17:42 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019
ChangeLog-2020
ChangeLog-2021
ChangeLog-2022
ChangeLog-2023 Rotate ChangeLog files. 2024-01-03 11:29:39 +01:00
config.h.in libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] 2024-01-17 11:49:11 +00:00
configure libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] 2024-01-17 11:49:11 +00:00
configure.ac libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318] 2024-01-17 11:49:11 +00:00
configure.host LoongArch: Adjust C++ multilib header layout. 2023-09-08 17:51:06 +08:00
crossconfig.m4
fragment.am
linkage.m4 libstdc++: Remove handling for underscore-prefixed libm functions [PR111638] 2023-11-11 00:41:08 +00:00
Makefile.am Update copyright years. 2024-01-03 12:19:35 +01:00
Makefile.in Allow overriding EXPECT 2023-12-22 10:24:56 +00:00
README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.