Reputation: 183
I'm wondering whether co_awaiting a coroutine with a temporary captured by reference is valid or not. So is the following code valid, I guess should the compiler put the temporary in the coroutine frame as for local variables:
task g(const S&);
task f() {
co_await g(S{});
}
On clang and msvc (https://godbolt.org/z/HqHae8), the temporary seems to be detroyed after g is resumed, whether on gcc (https://godbolt.org/z/hFWvU-) it seems that the temporary is destroyed after initial suspend.
Upvotes: 6
Views: 442