-
Notifications
You must be signed in to change notification settings - Fork 7
CWG2935 [dcl.fct.def.coroutine] Destroying the coroutine state when initial-await-resume-called is false #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Bump |
Do you know the exact behavior that's intended? If I remember correctly, the last time I looked at this, I had some difficulty in constructing a specification that would be satisfactory for all use cases. |
I believe the true intention of P0664R8 is that exceptions thrown before the initial suspend point will propagate to the coroutine's caller, while exceptions thrown after the initial suspend point can be caught in I wrote a simple test where the exception is thrown in
All three implementations have flaws. The key point is that ignoring the destruction of The solution I propose is:
UPDATE: The issue is essentially a duplicate of CWG 2562, and related issue CWG 2563 raises additional concerns about the details of Currently, the standard does not specify when The proposed additions are:
The latter will allow |
Full name of submitter: Brian Bi
Reference (section label): [dcl.fct.def.coroutine]
Issue description: According to [dcl.fct.def.coroutine]/11, the coroutine state is destroyed only when "control flows off the end" or when
.destroy()
is called on a coroutine handle.In [dcl.fct.def.coroutine]/5, suppose that an exception occurs at any point before initial-await-resume-called becomes true. Then [dcl.fct.def.coroutine]/11 does not state that the coroutine state is destroyed, nor does anything in this section state that the coroutine is suspended. Consequently, the caller is not able to destroy the coroutine state either and the coroutine state is leaked.
If the intent is to leak the coroutine state but still give the caller some means of observing the exception (e.g. log it and then terminate), this should be clarified in a note; otherwise, the implementation should either destroy the coroutine state or suspend the coroutine.
The text was updated successfully, but these errors were encountered: