<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110080>110080</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang++ outputs wrong warning for if constexpr and lambda capture combination
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
faithandbrave
</td>
</tr>
</table>
<pre>
```cpp
struct A {
static constexpr bool value = false;
};
struct B {
static constexpr bool value = true;
};
void h() {}
template <class T>
struct C {
void f() {
auto lambda = [this] {
if constexpr (T::value) {
g();
}
else {
h();
}
};
lambda();
}
void g() {}
};
int main()
{
C<A>{}.f();
C<B>{}.f();
}
```
outputs:
```
prog.cc:14:24: warning: lambda capture 'this' is not used [-Wunused-lambda-capture]
14 | auto lambda = [this] {
| ^
prog.cc:30:12: note: in instantiation of member function 'C<A>::f' requested here
30 | C<A>{}.f();
| ^
1 warning generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVNuuqzYQ_ZrhxUpkbAjhgYdcTr7gSH02MIArY1Nfctq_r0zYhJ2T3a2OomB5ZpbX8hpZOCd7jVhBfob8mojgB2OrTkg_CN3WVtwxqU37TwUH-vg10wT0CvTkvA2NJycCxfmxQwghzgsvG9IY7Tz-PVlSG6PIXaiABPiVdEI5BL50QHF9rreo5w3qd5Dehv9CvBvZkgHYEVg5oxbXbdrjOCnhI9SlUcI58hP4j09kLp8lzoDdBnDNxBDBG6LEWLdiZgf52Q_SQX79vTaG7DbKgB1_Aj8BP83y3h7wEf2DwaqWrMK2Vagcfo0xvGJs4gm3vdOP7EPhm_aX610vrH_nwG9mSe3JKKRegJeqDfwF-OUUDZph9t0rg5g_f51_Hv0xz9vTTfBT8C46sNl9KZ2s6fdNA_yUZsBPLP6RX8Jqqfu4XLxvxOSDRQKsmP1nBZGOaONJcNjGsdj9EXRc7x4du6UD8qeNaUaguPyPmYrVXwTkP14FcBpVsMhaG4_xKzWR2nmhvRReGk1MR0Yca7SkC7qZt4AVqw3zsHZRncW_AjqPLRnQ4kqK05nUd769Y78yTj_ul_So0QqP7f7Fm6SteFvyUiRYpQUrOOOHNE-GClleplkpihQPlB7KlB9y2hY0a3haHjNMZMUoy2jJDjSjhzzfN4znhcBjVrRtV2YFZBRHIdVeqfu4N7ZPpHMBqzSl9EgTJWpUbn5BGWuU0D0wFh9TW8WGXR16BxlV0nn3hPDSK6yW8jOwM1mGj_yyRver4M7Yz0-E0O3riDVmrKWe7UqCVdXg_TQPMbsBu_XSD6HeN2YEdovnL5_dZM2f2Hhgt1mPA3ZbJN0r9m8AAAD__-HFobs">