[Bug c++/95599] [coroutines] destructor for temporary operand to co_yield expression called before end of full-expression

lewissbaker.opensource at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 9 05:33:07 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95599

--- Comment #1 from Lewis Baker <lewissbaker.opensource at gmail dot com> ---
Note there is also some different behaviour if we change the example slightly
by removing awaitable::~awaitable() and leaving the awaitable type with a
trivial destructor.

See https://godbolt.org/z/ff5Uvy

In this case, instead of the resource destructor being called before the
coroutine suspends, the resource destructor is never called.

ie. observed output becomes:
```
resource()
awaitable::await_suspend()
awaitable::await_resume()
```


More information about the Gcc-bugs mailing list