<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92596>92596</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
CTAD: crashes on `clang::Expr::EvaluateAsConstantExpr`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
hokein
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hokein
</td>
</tr>
</table>
<pre>
clang current crashes on the following code.
```
template <typename>
constexpr bool C = true;
template<class T1, typename T2>
struct Foo {
template<class V> requires C<V> // Index of V in the Foo deduction guide is 2
Foo(V, T1);
};
template<class T3>
using AFoo = Foo<T3, T3>;
AFoo afoo{0, 1};
```
The `index` of template parameter occurrence `V` in the require-clause of the synthesized `AFoo` deduction guide `auto (T3, V) -> Foo<T3, T3>`is wrong (`2`), it should be `1`. We miss this case at https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplate.cpp#L2857-L2858.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU8uO4zYQ_JrWpTEGRVqvgw4eeQQEyC2Gc6aotsWEFhU-dmfy9QFl2ZvJIIcFDEomq4tV1Wrpvb7ORC0Ur8D5ZP8kPQPnUBwzGcNkXXvfywY7frTKyPmKKjpHc0DlpJ_Io50xTIQXa4z9rhPAjrQDdgR22NaSbb_1b6DbYmQgBNGFj4VmeSMQb_dDZWcf6H1xOFhrsEMQRwwuEojXz-UgOmWk93jKgXf4YMITf5L54KIK2FuLUG3liF8IziDe0NFfUTvy2IHo1h3gPfAef5lHekd7wTPqu9XEN9IYVdB2xmvUI6H2yB8X9NYCr89JVdLWPKVDdfzx_j9mxFN99CnNw6peHFdW0Z3ESruiHlQrRF6sheqVpeP800Wf07-vp4kQSqaTNyhZsvdsyyKdvFEgh1bdm61W8DkBtwi2tF6UkdHTWj4R-o85TOT13zSmgqQr1fw3KyiZjMEi8Ppu5wy8wZeU-VeTJdMevzs7XxMeSsaTFd4khA7oJxvNiMPKmkPJdoi_E9609xgm7VFJTygDTiEsHsTh3tWrDlMcdsregPfGfHs8XhZn_yAVgPeDsQPw_ibTSPTrt59AOm3-Rje5PU5bbDu1LMDFr7wuqpe01tsMYDa2YmxEIzNq8yovmqqqWZ1NbVHkiudCiKYpFdV7xXithnLP86Kq97LMdMsZ37MirzgTjJU7WVHBZFMLVV1K4nvYM7pJbXZJ-866a6a9j9Q2vGjKzMiBjN-G-25AHC7OzoHmcRtz1662h3j1sGdG--B_kAUdDLXd6XAEcfj3wEPJHnwgDm_vi9vevkkTZaCD79IcyzmsZyXLojPtT7dgNeOB96uffwIAAP__YWFo6w">