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

    <tr>
        <th>Summary</th>
        <td>
            Wrong error about not capturing an already local variable
        </td>
    </tr>

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

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

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

<pre>
    The original code from #57958 still fails.
See https://godbolt.org/z/MbYYYKfv1.
```C++
#include <type_traits>

template<auto F> concept constant_invocable = requires { typename std::integral_constant<int, (F(), 0)>; };

template<class T>
constexpr bool C =
  [](auto) {
    return not constant_invocable<[]() {
      T v;
      (void)T{v};
    }>;
 }(0);

static_assert(C<int>);
```
```console
<source>:10:15: warning: variable 'v' is uninitialized when used here [-Wuninitialized]
 (void)T{v};
              ^
<source>:14:15: note: in instantiation of variable template specialization 'C<int>' requested here
static_assert(C<int>);
              ^
<source>:9:10: note: initialize the variable 'v' to silence this warning
      T v;
 ^
          = 0
<source>:10:15: error: variable 'v' cannot be implicitly captured in a lambda with no capture-default specified
 (void)T{v};
              ^
<source>:7:3: note: in instantiation of function template specialization '(anonymous class)::operator()<int>' requested here
  [](auto) {
  ^
<source>:14:15: note: in instantiation of variable template specialization 'C<int>' requested here
static_assert(C<int>);
              ^
<source>:9:9: note: 'v' declared here
      T v;
        ^
<source>:8:35: note: lambda expression begins here
    return not constant_invocable<[]() {
 ^
<source>:8:36: note: capture 'v' by value
 return not constant_invocable<[]() {
 ^
                                   v
<source>:8:36: note: capture 'v' by reference
    return not constant_invocable<[]() {
 ^
                                   &v
<source>:8:36: note: default capture by value
    return not constant_invocable<[]() {
                                   ^
 =
<source>:8:36: note: default capture by reference
    return not constant_invocable<[]() {
                                   ^
 &
1 warning and 1 error generated.
Compiler returned: 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJz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