<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/87406>87406</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            poor diagnostic on invalid format string inside a lambda
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          janwilmans
      </td>
    </tr>
</table>

<pre>
    I know I'm using {fmt} here in the example but that is for the sake of comparison, the diagnostic is similarly bad with std::format, see the second godbolt link at the botton for an {fmt}-free example.

```
#include <fmt/core.h>
#include <string>
#include <functional>

// std::string example()
// {
//     return fmt::format("{.3}\n", 0);
// }

std::function<std::string()> example = []
{
    return fmt::format("{.3}\n", 0);
};

int main()
{
    return example().size();
}
```

when the format-string is invalid inside the lamdba, the diagnostic is very confusing. I can understand why, and I'm sure anything can be done about it, however, it seems to me that the error-handling strategy used in {fmt} is not working anymore in later versions of clang.

[godbolt link](https://cppcoach.godbolt.org/z/crnevsWeK) using {fmt} as an example of the `throw_format_error("invalid format string");` being displayed.
[godbolt link](https://cppcoach.godbolt.org/z/qTYf7accE) using std::format showing that inside a lamdba the std::format diagnostic is very poor 

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVUFv6zYM_jXyhajhSGmcHHxomgYodh0w7PRAW7StV1nKJLle3q8fJDsvSZed9opCkUKK-kh-H4Peq84QVex5z54PGY6ht676jmZSekDjs9rKc_UOH8ZO8M54OcDolemAlft2CKw8QE-OQBkIPQH9jcNJE9RjgNBjAOWhtS7ZPH4Q2BYaO5zQKW8N46_JIhV2xvqgmujv1aA0On2GGiVMKvTgg2TihYmX1roBQ7znieao1FgjobOytjqAVuYDMCRTbUOwJr2P5gr4qXX0E2nOigMrXpZ1Uyz_85ELZRo9SgImXuNlfmyso7xn4u2Riw9Ome4_jO1omqCsQX11WNyOjB-vOc5RLgAZ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