C++: Coroutine lambdas and the incomplete closure type
Arsen Arsenović
arsen@aarsen.me
Wed Aug 14 12:40:16 GMT 2024
Hi!
Currently, I'm looking at PR115731. To summarize the issue, it is
possible for the user to, through coroutines, observe the closure type
of a lambda before it is completed. This closure type, in GCC, is
started before and finished after parsing the lambda body, meaning that
it is incomplete during the parsing (and finishing) the lambda
operator(). As a result, when we attempt to resolve the promise type of
the coroutine, we can get an incomplete type error (as in the testcase
in the PR).
I was originally intending to defer expansion of CO_*_EXPRs up until
finishing the lambda operator(), by finishing the struct after pruning
captures and then expanding CO_*_EXPRs with a tree-walk, but this fails
because finishing the struct involves popping its binding level, but the
level stack contains the outermost binding level for the function at
that point.
I'm not sure if I can do that expansion later (defer it until after
finish_function (lambda_fn) or finish_struct (lambda_closure)) either
(in order to go back and recreate the CO_*_EXPRs in the lambda body, and
to "re-finish" the function, so that the coroutine transform gets
applied).
Is there a potential solution I am missing? Can one of the proposals
above be implemented somehow? What'd be the best thing to do?
TIA, have a lovely day.
--
Arsen Arsenović
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 381 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20240814/12c8c69f/attachment.sig>
More information about the Gcc
mailing list