| 1 |
// https://gcc.gnu.org/PR112341 |
| 2 |
#include <coroutine> |
| 3 |
struct A { int j; }; |
| 4 |
struct B { |
| 5 |
bool await_ready(); |
| 6 |
bool await_suspend(std::coroutine_handle<>); |
| 7 |
A await_resume(); |
| 8 |
}; |
| 9 |
struct C { |
| 10 |
struct promise_type { |
| 11 |
std::suspend_always initial_suspend(); |
| 12 |
std::suspend_always final_suspend() noexcept; |
| 13 |
void unhandled_exception(); |
| 14 |
C get_return_object(); |
| 15 |
void return_void(); |
| 16 |
B yield_value(auto) { return {}; } |
| 17 |
}; |
| 18 |
}; |
| 19 |
C f1(auto) { (co_await B()).j; } |
| 20 |
C f2(auto) { (co_yield 0).j; } |
| 21 |
void g() { f1(0); f2(0); } |