https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118074
--- Comment #10 from Iain Sandoe <iains at gcc dot gnu.org> --- (In reply to Weibo He from comment #9) > Thank you for your work. I noticed the heap-use-after-free issue might still > be present? > > https://godbolt.org/z/79bvTfWe5 I think this is because the design of that coroutine is such that the body has completed before it returns to the ramp (and therefore the original caller). This means that the promise has been destroyed (along with argument copies and the coroutine state frame). Recognised to be an unfortunate "gotcha" since there is no reliable way to determine that this has happened. There is an additional provision in the reworded CWG2563 that extends the lifetime of the promise until the return to the ramp - which we will implement (hopefully soon).