<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146063>146063</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Regression with lambda return type deduction
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++17,
c++20,
regression,
rejects-valid,
lambda,
constexpr
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
The following used to compile without diagnostic in Clang 20.1:
```
template<class T, class U>
struct is_same {
static constexpr bool value = false;
};
template<class T>
struct is_same<T, T> {
static constexpr bool value = true;
};
template <typename T, int N>
struct A {
static_assert([]() constexpr { // error: value of type 'void' is not contextually convertible to 'bool'
if constexpr (is_same<T, int>::value)
return true;
else
return (10 != N);
}());
};
int f1() {
if constexpr (false) {
A<int, 256> a;
}
return 0;
}
```
but now gives an error on trunk: https://godbolt.org/z/fd5WY4xhY
Note, if you remove the `if constexpr (false)` from `f1()`, then the code compiles. If you add `-> bool` to the lambda, the code also compiles.
The code compiles without diagnostics in GCC, MSVC, and EDG.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEVMFu4zYQ_ZrxZRCDGlpSfNBBVtaLHppDm7bY04KSKJstTRok5ST9-mIk2_EaKVYwIHrEmffmvSFVjGbntK4g30D-tFBj2vtQ1Sp4t1HWHpRbtL5_r172GgdvrX81bodj1D0mj50_HI3V-GrS3o8Je6N2zsdkOjQOG6vcDkksM5A1iBoKcf6JOunD0aqkQTadVTHiC1CD8_IPkF9A1DGFsUto4veoDhqh3ICoEWNSXL_zLib9dgzYem_xpOyoEeQTDspGDZI3Q_k0L_BzxE9gQDYTE_54gfwZYgrjPeANHoJs0vtRO25iqm1cwucfwOtrd_zMeN9VjDokoMfZG17Q-oYFlBsE2gJtUYfgA8j6TMoPyIgIVJ686YFKNBGdT5yd9FsalbXv_OekQzKt1WwmUMmNAZVXJohmuEWkxzuZj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