https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95111
--- Comment #15 from Avi Kivity <a...@cloudius-systems.com> --- I believe that my suggestion works for mutable lambdas (and for any coroutine called as a member function): - if the object passeed to the member function is an lvalue, then the coroutine captures a reference to the object - if the object passed to the member function is an rvalue, then the coroutine captures the object by copying it (typically using it move constructor). Examples: auto a = [blah] () mutable -> task<> { ... }; a(); // a is captured by reference [blah] () mutable -> task<> { ... } (); // captured by value my_class a; a.some_coroutine(); // captured by reference my_class a; std::move(a).some_coroutine(); // captured by value Currently, the "captured by value" cases are captured by reference, and cause a use-after-free if the coroutine outlives the caller scope.