<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98740>98740</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[coroutines] Wrong behavior of await_suspend()
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ddvamp
</td>
</tr>
</table>
<pre>
There are three versions of await_suspend(). The standard does not prohibit the resuming of coroutines through the handle from these functions. However, if you do this in the version of the function that returns bool, strange behavior is detected. If false is returned, the coroutine will resumed not from the actual suspension point, but from the point from which it entered the current await_suspend call. The same situation is observed in gcc. I guess this may be the result of incorrect optimization.
A minimal example:
```
bool await_suspend(auto h) {
h.resume();
return false;
}
```
https://godbolt.org/z/KM63dooae
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU11v6zYM_TXyC1HDkT8SP_ihXRCsGPZWYI-DZNGWBlkyJCpZ--sH2Wm6e2-BQAEl8pzDY1LEaGaHOLD2hbXnQiTSPgxKXcWyFtKr9-FNY0AQAYF0QIQrhmi8i-AnEDdh6O-Y4opOMX5ivC_hTSNEEk6JoEB5jOA8wRq8NtIQkEYIGNNi3JwxRh98IuMwZgKfZr2laOGURZiCX3IcEabkRsrMJfzub3jFwPhvYCZ49wmUB9ImgnFb9V1kxs_hZymQFgQBKQUXQXpvM0SkINyMIFGLq_EBTASFhCOhKuF1gknYiPl2r0SVqzLuQzvcjLV7W6i2fj-FgxgpCQu7SZuo1RtHGUKm_-Vtt3t402bUYAjQEQZUO1cKAR396DmMwtq75WJBiIaS2Do1EbyMGK6osinzOJbwCnPCGHenFvEOEh-fw1I2y7jRh4AjgV_JLOZjAytZdWbV834-w2KcWYQF_Fcsq0VW319YV91_W5jt_WVCRCIPmvEe2PFlzwPQ5e7cPkGsfjzsfu_-P67Z8fwt335qojVmSfzC-GX2SnpLpQ8z45cPxi9__NnVynuBhRpq1de9KHA4HHl16nretIUeamxOoj9IOda1rKam7ttj17VTO7aNGKUszMAr3lTHQ304HJqqLTsuT1zWPVeN6jolWFPhIowtrb0umbswMSYc-tOxqQorJNq4bRznDm-wPTLO8wKGIdc8yTRH1lTWRIpfKGTIbqv6tTOsPcNfwbv5a3q_38siBTv8ZI4hnWQ5-oXxSya5_z2twf-DIzF-2aRFxi-79OvA_wsAAP__FkVmvQ">