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

    <tr>
        <th>Summary</th>
        <td>
            Clang 19.1.0 - Extremely poor error message when dealing with callback functions and std::format
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          9291Sam
      </td>
    </tr>
</table>

<pre>
    Here's an MRE for this error.

[https://godbolt.org/z/b4sErhzqb](https://godbolt.org/z/b4sErhzqb)

```cpp
#include <iostream>
#include <vector>
#include <concepts>

struct CallBack
{
 void callback(std::invocable<int, std::size_t> auto func)
    {
        for (std::size_t i = 0; i < foo.size(); ++i)
        {
            func(foo[i], i);
        }
    }

    std::vector<int> foo;
};

void caller()
{
 CallBack c {};

    c.callback(
        [&](int i, std::size_t s)
 {
            // the error is below, there are 4 {} which correspond with only 3 arguments
            std::cout << std::format("{} {} {} {}", s, i, false);
        });
}
```

->
```cpp
<source>:11:13: error: call to immediate function 'caller()::(anonymous class)::operator()' is not a constant expression
   11 |             func(foo[i], i);
      | ^
<source>:22:7: note: in instantiation of function template specialization 'CallBack::callback<(lambda at <source>:23:9)>' requested here
   22 | c.callback(
      |       ^
<source>:11:18: note: implicit use of 'this' pointer is only allowed within the evaluation of a call to a 'constexpr' member function
   11 |             func(foo[i], i);
      | ^
1 error generated.
Compiler returned: 1
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVc9yszYQfxr5shMPSCbYBw62Y08vvbQP0FnE2qgVEp8knC95-s4CJn8P7cyX8QTQSrv7-yMJYzRXR1SJ4iCKpxUOqfWh2sld_id2q9o3L9VvFEjIMgI6-P2PE1x8gNSaCBSCD2uR7flXHNqU-ijUXsizkOerb2pv09qHq5DnVyHP9SaeQvv6oxbFk5Db_z5d7uYaj9n0033Pn1IZp-3QEAh1ND6mQN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