upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/cpp_unwind_test.cpp
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 22:41:03 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 22:41:03 -0500
commit2d3369a4c82e6f36c5190c4c534d3df600e135ec (patch)
tree645518e91fee1ab6299170a3251c035495000c75 /runtime/test/cpp_unwind_test.cpp
parentdb51b7d3f999ab57898cf039f8289d807b63523c (diff)
parent7b7d73f890f9fbbf5967bbb694390bbc99e33ba6 (diff)
Merge remote-tracking branch 'origin/main'
Diffstat (limited to 'runtime/test/cpp_unwind_test.cpp')
-rw-r--r--runtime/test/cpp_unwind_test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/runtime/test/cpp_unwind_test.cpp b/runtime/test/cpp_unwind_test.cpp
new file mode 100644
index 000000000..30cfc6ca1
--- /dev/null
+++ b/runtime/test/cpp_unwind_test.cpp
@@ -0,0 +1,31 @@
1#include <cstdio>
2
3namespace {
4
5struct UnwindMarker {
6 bool& destroyed;
7 ~UnwindMarker() { destroyed = true; }
8};
9
10struct TestException {};
11
12// Keep the object in a separate frame, outside the catch handler's function.
13__declspec(noinline) void throw_with_marker(bool& destroyed) {
14 UnwindMarker marker{destroyed};
15 throw TestException{};
16}
17
18} // namespace
19
20int main() {
21 bool destroyed = false;
22 try {
23 throw_with_marker(destroyed);
24 } catch (const TestException&) {
25 if (destroyed) return 0;
26 std::fputs("C++ exception unwound without running a destructor\n", stderr);
27 return 1;
28 }
29 std::fputs("Expected a C++ exception\n", stderr);
30 return 1;
31}