[libcxx-commits] [PATCH] D116381: [libc++][format] Fix precision parser conformance.

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 29 15:00:49 PST 2021


CaseyCarter added a comment.

> @CaseyCarter reported the std-format-spec parser prohibits leading zeros

Technically, I reported that the _test_ expects the std-format-spec parser to reject leading zeroes for precision, which the Working Draft does not require.  I wouldn't write this silly format-spec even if it is allowed, but I did notice that MSVC STL fails this test.



================
Comment at: libcxx/test/std/utilities/format/format.functions/format_tests.h:180
+  check_exception(
+      "A format-spec arg-id should terminate at a '}'",
+      STR("hello {0:{01}}"), world, 1);
----------------
Quuxplusone wrote:
> It would be friendlier to make this message `"A format-spec arg-id shouldn't have leading zeros"`.
> Also (definitely unrelated to this PR) I think it's superfluous to keep repeating the word `format-spec` in all these messages. The exception type is already `format_error` and it's thrown during format-string parsing, right? I think `"An arg-id shouldn't...` would be perfectly unambiguous to the catcher.
+1 for "... shouldn't have leading zeroes". A user who mistakenly believes that `01` is a valid _arg-id_ will read this message, see all the `}`s in the format string, and spend an hour investigating the wrong thing / filing a bug report when we could have pointed them directly at the problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116381/new/

https://reviews.llvm.org/D116381



More information about the libcxx-commits mailing list