https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115905
Bug ID: 115905
Summary: [coroutines] Wrong behavior of await_suspend()
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ddvamp007 at gmail dot com
Target Milestone: ---
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 clang. 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