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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Wrong constraint evaluation for lambda in unevaluated context
        </td>
    </tr>

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

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

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

<pre>
    The following should be valid C++20 code:
```c++
template <class T>
using F = decltype([] (auto a) requires (sizeof(T) > sizeof a) {});

int main() {
 F<int> f;
    f(char{});
}
```

Clang rejects with:
```console
<source>:6:5: error: no matching function for call to object of type 'F<int>' (aka '(lambda at <source>:2:20)')
    6 | f(char{});
      |     ^
<source>:2:20: note: candidate template ignored: constraints not satisfied [with a:auto = char]
    2 | using F = decltype([] (auto a) requires (sizeof(T) > sizeof a) {});
      | ^
<source>:2:42: note: because 'sizeof(char) > sizeof a' (1 > 1) evaluated to false
    2 | using F = decltype([] (auto a) requires (sizeof(T) > sizeof a) {});
      |                                          ^
```

Somehow it got `char` substituted into `T` in `sizeof(T)`?

See https://compiler-explorer.com/z/YvnzozWvx.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVE2PozgQ_TWVS2kisEMIBw4k6dz2tJFGezSmAO8aO2ubdE__-lURZvpjNNKedlEikKv8qt6rDxWjGRxRDcURivNGzWn0of5NDeSSugai0c-RNq3vvtXXkbD31vpn4waMo59thy3hXVnT4QnEEcRRZKh9RyAbyBrYZ4-ffhghaxJNN6sSIciTtipGvIJ8gqyZI6NeEOQZO9I2fbsRiMMjMQRxUHPyqEBUGOjv2QSKfBrNK_kexOHKFpBP-Dh5eEJ5hPIMogLJwSFrjEs4KeMYenXIGryAPBmX-Hr_cEVEZFg9qvAZpTy_5_bAPVnlBgz0J-kU8dmk8bME3kVviY_kKfo5aGListmDbAqQDVIIPvCH8zippEcWpJ-dTsY77H1ArazF5NG3HAZ9j6wSgijfCIAoF7X-UnwO4mDV1HYKVcJPgQX_M6bFftVKeo9Qnn5FHZeHHZZ38fQznRV1oZG4D1Ar15mOa_6j-GZwPlC3WL2LKSjjUuQbGFUysTfUIRRH1hEVyGYpPrfGklRxXnMRSy7_Reu8Mf8l6514z7olrea4FOdHoCX5n2It9cqXw5ytdFd2Vok6LnWvbKT_ke2_flZZPk7F736i0T-jSTj4hDwGLME-wzi3MZk0M03juLj77MoG4_jzQ7YMJy8rIhGOKd0ij5e4gLhoP92MpfCFXm7WBwpb7ScQl1cQlz_u7tW_fr2_bDddLbtKVmpDdV7Kstrt8qrajHXV73vqBe3yoiuk3HdCtVp1h7JoD7k-yI2pRSaKLBdlJvK9rLZFT0W7z9p8V8lWyhJ2GU3K2K2192nrw7AxMc5U52K3q8qNVS3ZuGxYITSvCRCCl22o-cKXdh4i7DJrYopvEMkku6zlZbFwZb8G74Z34_K9T74vh3XOjcPZvbWQ9i7RS9rMwdYfdRtMGud2FYvjrq8vt-B5vYC4LDwiiMtK5V6LfwIAAP__OvPLAQ">