<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68651>68651</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Wexit-time-destructors diagnoses usage in discarded statements
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkasting
</td>
</tr>
</table>
<pre>
The following code generates a warning when compiled with `-Wexit-time-destructors`, even though no exit-time destructor is generated:
```
struct T { ~T(); };
struct S {
T t;
};
void foo() {
if constexpr(false) {
static S s;
}
}
```
Online repro: https://godbolt.org/z/n66e93f45
It seems like this warning should only be evaluated after discarded statements from a `constexpr if` are removed, or else needs to take the discard state into account?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0U01vnDAQ_TXmMtqVMSwfBw7ZRkg99ZCVejZ4ADfGXnmG3aSH_vYKtt2kUSohI5g3b-bN82giO3rERhyO4vCY6IWnEJvzsya2fky6YF6b04QwBOfC1foR-mAQRvQYNSOBhquOfg1cJ_TQh_lsHRq4Wp5AFHL3HV8s79jOuDNIHJeeQyRRSKG-AF7QA09hGSfwAe5QeIOCpXs5I7IHIR-FfFjzb8_2eQPDCUR5hF8noSqhapEdQZSPIjv-A3paQbc_ACfge_w99nZegjUwhHDje59nB-iDJ8aXcxSqGrQj_AABINZse3gCuvPC1tG93Gdabuc376xHiHiOQWQPMDGfaZWvWqHaMZguON6HOArV_hSq9UWBdTbkh_ckXxkIcSZw9hmBJ0t3t2gKizMQvHuFDgEv2i3rhEEPjBGMpV5Hg2YTgTN6JhhimEGvrt61gx1EIUHHtdU5XNCstoYI6AjBIxoCDsB6q49_eW-sYD0H0H0fFs8iaxPTZKbOap1gkxZ1UctUljKZGllgXRYdln2P9aEo87QvDroaZNlXWuVVYhslVZbKVMpU5Zncp0OuZFl2XVcNVV6mIpc4a-v2zl3mdWyJJVqwKarikCZOd-hoWwKlPF5hCwql1p2IzZqz65aRRC6dJaY3FrbssPnPJQdj9egDIcFCelz1fjrYZImu-WCw5Wnp9n2YhWrXan9eu3MMP7BnodqtRxKq3TT8DgAA__-RfzGj">