Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/torture/pr120243-unhandled-1.C

raw
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_never initial_suspend() const noexcept { return {}; }
11 std::suspend_never final_suspend() const noexcept { return {}; }
12
13 void unhandled_exception() { throw; }
14
15 coro get_return_object() { return {}; }
16 void return_void() {}
17
18 };
19 };
20
21 int main() {
22 auto c = []() -> coro {
23 throw "hello";
24 __builtin_abort();
25 co_return;
26 };
27 try {
28 c();
29 }
30 catch(...) {
31 __builtin_printf("Caught!\n");
32 }
33 }