libstdc++: The Trouble with Tribbles
authorJonathan Wakely <jwakely@redhat.com>
Mon, 5 Dec 2022 12:23:57 +0000 (12:23 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 6 Dec 2022 21:33:29 +0000 (21:33 +0000)
commit48e21e878b2c6cfc7797088a7393a735de75883c
treea9cf68c07d14eccf8aaa5f6a1a5d0ea724dc64a8
parentba1536dac780f3f92c5eab999fda6931f6247fc1
libstdc++: The Trouble with Tribbles

Fix digit grouping for integers formatted with "{:#Lx}" which were
including the "0x" prefix in the grouped digits. This resulted in output
like "0,xff,fff" instead of "0xff,fff".

Also change std:::basic_format_parse_context to not throw for an arg-id
that is larger than the actual number of format arguments. I clarified
with Victor Zverovich that this is the intended behaviour for the
run-time format-string checks. An out-of-range arg-id should be
diagnosed at compile-time (as clarified by LWG 3825) but not run-time.
The formatting function will still throw at run-time when args.arg(id)
returns an empty basic_format_arg.

libstdc++-v3/ChangeLog:

* include/std/format (basic_format_parse_context::next_arg_id):
Only check arg-id is in range during constant evaluation.
* testsuite/std/format/functions/format.cc: Check "{:#Lx}".
* testsuite/std/format/parse_ctx.cc: Adjust expected results for
format-strings using an out-of-range arg-id.
libstdc++-v3/include/std/format
libstdc++-v3/testsuite/std/format/functions/format.cc
libstdc++-v3/testsuite/std/format/parse_ctx.cc