Skip to content

cpp coro recursively task "coroutine transformation" wrong #518

@oncealong

Description

@oncealong

https://godbolt.org/z/fcsPfevzW

the code above is from noop_coroutine.
when "coroutine transformation", the code

    task<int> v = get_random();
    task<int> u = get_random();
    std::cout << "in test()\n";
    int x = (co_await v + co_await u);

transform to

        __f->v = get_random();
        __f->u = get_random();
        std::operator<<(std::cout, "in test()\n");
        __f->x = (
                /* co_await insights.cpp:103 */
                __f->__suspend_103_14 = __f->v.operatorco_await();
        if(!__f->__suspend_103_14.await_ready()) {
            __builtin_coro_resume(__f->__suspend_103_14.await_suspend(std::coroutine_handle<task<int>::promise_type>::from_address(static_cast<void *>(__f)).operator coroutine_handle()).address());
            __f->__suspend_index = 2;
            return;
        }

        __resume_test_2:
        __f->__suspend_103_14_res = __f->__suspend_103_14.await_resume();

        /* co_await insights.cpp:103 */
        __f->__suspend_103_27 = __f->u.operator co_await();
        if(!__f->__suspend_103_27.await_ready()) {
            __builtin_coro_resume(__f->__suspend_103_27.await_suspend(std::coroutine_handle<task<int>::promise_type>::from_address(static_cast<void *>(__f)).operator coroutine_handle()).address());
            __f->__suspend_index = 3;
            return;
        }

        __resume_test_3:
        __f->__suspend_103_27_res = __f->__suspend_103_27.await_resume();
        );

the transform code __f->x = not grammatical.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions