| 1 |
// PR c++/120243 |
| 2 |
// { dg-do run } |
| 3 |
|
| 4 |
#include <coroutine> |
| 5 |
|
| 6 |
struct coro { |
| 7 |
struct promise_type { |
| 8 |
promise_type() = default; |
| 9 |
|
| 10 |
std::suspend_always initial_suspend() const noexcept { return {}; } |
| 11 |
std::suspend_always final_suspend() const noexcept { return {}; } |
| 12 |
|
| 13 |
void unhandled_exception() { throw; } |
| 14 |
|
| 15 |
coro get_return_object() { return {std::coroutine_handle<promise_type>::from_promise(*this)}; } |
| 16 |
void return_void() {} |
| 17 |
}; |
| 18 |
|
| 19 |
std::coroutine_handle<promise_type> h; |
| 20 |
}; |
| 21 |
|
| 22 |
int main() { |
| 23 |
auto c = []() -> coro { |
| 24 |
throw "hello"; |
| 25 |
__builtin_abort(); |
| 26 |
co_return; |
| 27 |
}; |
| 28 |
try { |
| 29 |
c().h.resume(); |
| 30 |
} |
| 31 |
catch(...) { |
| 32 |
__builtin_printf("Caught!\n"); |
| 33 |
} |
| 34 |
} |