[libcxx-commits] [PATCH] D121530: [WIP][libc++][format] Implement format-string.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 23 13:00:28 PDT 2022


Mordante marked an inline comment as done.
Mordante added inline comments.


================
Comment at: libcxx/test/std/utilities/format/format.functions/format.pass.cpp:51
+  // A basic ill-formed test is done in format.verify.cpp
+  // The exceptions are tested by other functions that don't use the basic-format-string as fmt argument.
 };
----------------
ldionne wrote:
> Is it not possible to call `std::format` with a non-constant format-string, in which case I would assume that we still get an exception? If so, we should test it too.
No that's not possible. The new helper class basic-format-string (http://eel.is/c++draft/format#fmt.string) has a `consteval` constructor. If you have a non-constant format-string you can use `std::vformat` instead of `std::format`. Something like `std::vformat(fmt, std::make_format_args('a', 42'));`

The test for `vformat` will test all exceptions and `format` won't test the exceptions. A generic test to see whether these invalid format-strings are ill-formed has been added. But that tests only tests a few corner cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121530



More information about the libcxx-commits mailing list