Skip to content
Snippets Groups Projects
Commit 2a8ee259 authored by Jonathan Wakely's avatar Jonathan Wakely
Browse files

libstdc++: Implement P2905R2 "Runtime format strings" for C++20

This change makes std::make_format_args refuse to create dangling
references to temporaries. This makes the std::vformat API safer. This
was approved in Kona 2023 as a DR for C++20 so the change is implemented
unconditionally.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (__formatter_chrono): Always use
	lvalue arguments to make_format_args.
	* include/std/format (make_format_args): Change parameter pack
	from forwarding references to lvalue references. Remove use of
	remove_reference_t which is now unnecessary.
	(format_to, formatted_size): Remove incorrect forwarding of
	arguments.
	* include/std/ostream (print): Remove forwarding of arguments.
	* include/std/print (print): Likewise.
	* testsuite/20_util/duration/io.cc: Use lvalues as arguments to
	make_format_args.
	* testsuite/std/format/arguments/args.cc: Likewise.
	* testsuite/std/format/arguments/lwg3810.cc: Likewise.
	* testsuite/std/format/functions/format.cc: Likewise.
	* testsuite/std/format/functions/vformat_to.cc: Likewise.
	* testsuite/std/format/string.cc: Likewise.
	* testsuite/std/time/day/io.cc: Likewise.
	* testsuite/std/time/month/io.cc: Likewise.
	* testsuite/std/time/weekday/io.cc: Likewise.
	* testsuite/std/time/year/io.cc: Likewise.
	* testsuite/std/time/year_month_day/io.cc: Likewise.
	* testsuite/std/format/arguments/args_neg.cc: New test.
parent 37a4c5c2
No related branches found
No related tags found
No related merge requests found
Showing
with 93 additions and 47 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment