These pass now; the first was fixed by r16-1507.
PR c++/120243
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/torture/pr120243-unhandled-1.C: New test.
* g++.dg/coroutines/torture/pr120243-unhandled-2.C: New test.
--- /dev/null
+// PR c++/120243
+// { dg-do run }
+
+#include <coroutine>
+
+struct coro {
+ struct promise_type {
+ promise_type() = default;
+
+ std::suspend_never initial_suspend() const noexcept { return {}; }
+ std::suspend_never final_suspend() const noexcept { return {}; }
+
+ void unhandled_exception() { throw; }
+
+ coro get_return_object() { return {}; }
+ void return_void() {}
+
+ };
+};
+
+int main() {
+ auto c = []() -> coro {
+ throw "hello";
+ __builtin_abort();
+ co_return;
+ };
+ try {
+ c();
+ }
+ catch(...) {
+ __builtin_printf("Caught!\n");
+ }
+}
--- /dev/null
+// PR c++/120243
+// { dg-do run }
+
+#include <coroutine>
+
+struct coro {
+ struct promise_type {
+ promise_type() = default;
+
+ std::suspend_always initial_suspend() const noexcept { return {}; }
+ std::suspend_always final_suspend() const noexcept { return {}; }
+
+ void unhandled_exception() { throw; }
+
+ coro get_return_object() { return {std::coroutine_handle<promise_type>::from_promise(*this)}; }
+ void return_void() {}
+ };
+
+ std::coroutine_handle<promise_type> h;
+};
+
+int main() {
+ auto c = []() -> coro {
+ throw "hello";
+ __builtin_abort();
+ co_return;
+ };
+ try {
+ c().h.resume();
+ }
+ catch(...) {
+ __builtin_printf("Caught!\n");
+ }
+}