libstdc++: Improve diagnostics for invalid std::format calls
authorJonathan Wakely <jwakely@redhat.com>
Thu, 13 Apr 2023 15:34:51 +0000 (16:34 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 14 Apr 2023 10:58:39 +0000 (11:58 +0100)
commit6a9547f3ca6c48f116478169d5fc62165dde7f43
tree7b1cabf4790f70ec44103b969be04e790d8de9ea
parentb0e85485fbf042abccee5c0a9eb499da386c8db3
libstdc++: Improve diagnostics for invalid std::format calls

Add a static_assert and a comment so that calling std::format for
unformattable argument types will now show:

/home/jwakely/gcc/13/include/c++/13.0.1/format:3563:22: error: static assertion failed: std::formatter must be specialized for each format arg
 3563 |       static_assert((is_default_constructible_v<formatter<_Args, _CharT>> && ...),
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and:

  140 |       formatter() = delete; // No std::formatter specialization for this type.

libstdc++-v3/ChangeLog:

* include/std/format (formatter): Add comment to deleted default
constructor of primary template.
(_Checking_scanner): Add static_assert.
libstdc++-v3/include/std/format