<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69219>69219</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`-Wunreachable-code` and coroutines.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
asoffer
</td>
</tr>
</table>
<pre>
The `-Wunreachable-code` warning triggers on code of this form:
```
task f() {
std::abort();
co_return;
}
```
While it's true that `co_return` is never executed, one cannot remove the `co_return` without changing the semantics of the program. This is the simplest mechanism one can use to write a never-returning coroutine, and should therefore not be flagged. As a current workaround, one can spell this as
```
task f() {
co_return [&] { std::abort(); }();
}
```
but ideally when unreachable code is used to determine the semantics of the function/coroutine, it should not trigger `-Wunreachable-code` warning.
Reproduction:
https://godbolt.org/z/7EoEcf4M9
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE1v7CgQ_DX40hoL46_44EOyE9_2soqU4wqbts0GwwiazGZ__YpxJh_vJXp6koUFTRdFVQkZgl4sYs_qO1YfMxlpdb6Xwc0z-mx06qV_WBFYww-P0XqU0ypHg4fJKWQNh7P0VtsFyOtlQR_AWUg1cDPQqgPMzm-svGX8yPh1bPjrd5mSDE8wM3HDRAesvdtXAQKp1FjeytF52uusvJYn97dHit6-LbH2-CX-Pj6u2iBoYqINQD4i0CopXewdqeGgA1h8Rg_4L06RUDHxBziLMElrHYHHzT2nXvyp9axpdZFgWqVdLpqsCAE3aUlPYRcE4eTd4uWWw0NSR4d9l95OBgPBhqlbh-16JsSAQA7OXhOC3Mkd9kPTGZPzLpK2mHhKqyCsLhqVUD3OziMk1iPCbOSyoMrhNoCEKXqPluDs_JP0LtqP94RwQmN2-2SA3zIN3o2BlCnRsPqYNnxnJyTbPnv7nZFjJNAKpTEvcF7RwodA7qHTIemlkmAKCf2mLX5twxztRNpZJoZPEmq6Kph0e031L-Off0zaX3jyTsUd_pr8legU0kwMTAyLU6MzlDu_MDH8x8TQ3rv7aa7-7PbtmepL1ZWdzLAvmq6tmpuiKbK1bwtZCN7KsZ7LYuRYyZHPnVTdWLd8wptM94KLsuBFU1R1w4scx0nVXFRNU9Ulr0dWcdykNrkxz1tikOkQIvZNJ4ouM3JEEy7PgRAWz3ApMiHS6-D71HMY4xJYxY0OFN5RSJPB_lulUjbflA55Fr3pfxBF0xrHfHIbE0OCff0dTt79gxMxMVzIBCaGC9n_AwAA__-3zn3u">