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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Call to lambda expressions in unevaluated context is improperly rejected by Clang
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            rejects-valid
      </td>
    </tr>

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

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

<pre>
    I'm not confident that I'm summarizing the issue accurately, but here is an example of the case that I discovered while at https://github.com/llvm/llvm-project/issues/70601.
```cpp
template <class T>
struct S {
  template <class U>
  using Type = decltype([]<class V> {
    return V();
  }.template operator()<U>());
};

S<int>::Type<int> V;
```

Clang currently rejects the above, complaining that there are no viable functions, which I think is suspicious.

```txt
<source>:6:14: error: no matching member function for call to 'operator()'
    4 |   using Type = decltype([]<class V> {
      |                         ~~~~~~~~~~~~~
 5 |     return V();
      |     ~~~~~~~~~~~
    6 |   }.template operator()<U>());
      |   ~~~~~~~~~~~^~~~~~~~~~~~~
<source>:9:9: note: in instantiation of template type alias 'Type' requested here
    9 | S<int>::Type<int> V;
      |         ^
<source>:4:25: note: candidate function template not viable: no known conversion from '(lambda at <source>:4:25)' to 'const S<int>::(lambda at <source>:4:25)' for object argument
    4 |   using Type = decltype([]<class V> {
      | ^
1 error generated.
```

The example is also on [godbolt](https://godbolt.org/z/EzsMY73x1), and we can see that this is accepted by both MSVC and GCC.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VcFu4zYQ_Rr6MlhDIi3LPvjgyHGxhz1tGqBHihpb7FKkSlJOnEO_vRhKUYwkBRZbVEgihcOZeZx5fCND0GeLuGPFHSsOCznE1vndy9VmPC8XtWuuu6-Mlx1YF0E5e9IN2gixlRFGQxi6Tnr9ou0ZYougQxgQpFKDlxHNlfEK6iFCi56MIC3gs-x6g-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