Skip to content

get_return_object() is called to late #740

@ARG-Helper

Description

@ARG-Helper

https://compiler-explorer.com/z/aWE1Y3zdT is transformed into https://compiler-explorer.com/z/M4ovrnhda
the first outputs:

get_return_object()
~promise_type()

the second outputs:

~promise_type()
get_return_object()

calling get_return_object() on a destroyed object

 /* Call the made up function with the coroutine body for initial suspend.
   This function will be called subsequently by coroutine_handle<>::resume()
   which calls __builtin_coro_resume(__handle_) */
__fooResume(__f);


return __f->__promise.get_return_object();

should have been

/*NRVO is mandatory for this assignment*/
 auto __coro_gro=__f->__promise.get_return_object();
/* Call the made up function with the coroutine body for initial suspend.
   This function will be called subsequently by coroutine_handle<>::resume()
   which calls __builtin_coro_resume(__handle_) */
__fooResume(__f);


return __coro_gro;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions