[Bug c++/100127] [coroutines] internal compiler error compiling promise with custom awaiter

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Dec 17 16:58:10 GMT 2021


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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:

https://gcc.gnu.org/g:2466a8d0dd40d05cb4a239d7d4a21bbd9ffab698

commit r12-6046-g2466a8d0dd40d05cb4a239d7d4a21bbd9ffab698
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sat Oct 2 17:20:08 2021 +0100

    coroutines: Handle initial awaiters with non-void returns [PR 100127].

    The way in which a C++20 coroutine is specified discards any value
    that might be returned from the initial or final await expressions.

    This ICE was caused by an initial await expression with an
    await_resume () returning a reference, the function rewrite code
    was not set up to expect this.

    Fixed by looking through any indirection present and by explicitly
    discarding the value, if any, returned by await_resume().

    It does not seem useful to make a diagnostic for this, since
    the user could define a generic awaiter that usefully returns
    values when used in a different position from the initial (or
    final) await expressions.

    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

            PR c++/100127

    gcc/cp/ChangeLog:

            * coroutines.cc (coro_rewrite_function_body): Handle initial
            await expressions that try to produce a reference value.

    gcc/testsuite/ChangeLog:

            * g++.dg/coroutines/pr100127.C: New test.


More information about the Gcc-bugs mailing list