<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/131080>131080</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`if constexpr` appears to not work correctly in some nested templates
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
HolyBlackCat
</td>
</tr>
</table>
<pre>
I think I've seen similar tickets at some point, so this could be a duplicate.
The following code doesn't compile, but it should: https://gcc.godbolt.org/z/648eY8eh5
```cpp
template <typename T>
struct FalsePredicate
{
static constexpr bool value = false;
};
template <typename T, template <typename> typename Cond>
void foo()
{
[]<template <typename> typename Cond2 = Cond>
{
if constexpr (Cond2<T>::value)
T::foo();
}();
}
int main()
{
foo<int, FalsePredicate>();
}
```
It says that `T::foo()` is invalid for `T=int`, despite there being `if constexpr`.
Tested on Clang 20 and trunk.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMlE9v8zYMxj8NcyHeQJYS2zn44CYN1tsOvewoS3SsRZYMi06XffrBdvq2e9sBCwL4j8Tf85AirVNyl0BUwf4J9qeNnriLY_Vb9Pcnr831qHnTRHuvXpA7F674ArK4ESaigMn1zusR2ZkrcULNmGJPOEQXGOQRU5yjEpo4eYsNoUY7Dd4ZzbQFUYOoXzvCNnof31y4oImW0EZKAWTBaGI_OE8zqpkYHWPqZhSoGjvmIYGqQZ5Bni_GbC_RNtHzNo4XkOe_QZ7zXUl_lNTtVy3Ixfo3wwCiZuoHr5kQ1JHvAwXdE76CegZRJx4nw3jWPtHvI9nF8owonkDUiIiJNTuDJobE9NcwYhOjx5v20ww8YTuHgnpagk6Pm_8UlUf8bgXUM_7cdYzBru5u0VlsYwRZgjz8y9Z6jjPi_-DkYvUDvBBWlms_5QayXLaDOi4FUjWoesl11cdPv9d19cOe-umtOH1-NT8uNXGBsdcufJPOTFHHRzv9chrq-Rva-xGv5BfGpO8JudOMkIsv3nKBLqELN-2Xko6PXadZMhezqqU0OCbkjkbChuY-hVx8rg_k4r2dKTFZjAGPXocLSoE6WORxCtftxlbKHtRBb6jKil1W7sp9ttt0laEyz7NCGKvbRhRZu8_3B6ukaSUVzeGwcZUUci9UpkS-K9Vua6VWUpApykxlbdbCTlCvnd96f-vnCdi4lCaqMpWJUmy8bsinZcilDPSGyypIOc_8WM1BP5rpkmAnvEucPjDs2FP1NV_Uw0B6TMgRQ2R8i-MVTRxHMuzv6ML6KQhrPd6bMW2m0Ve_jK7jbmq2JvYgz7Pu4_JjGOOfZBjkeXGbQJ4f6dwq-U8AAAD__7F0cf8">