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:
authorDanielDeGiorgio <degiorgiodaniel1808@gmail.com>2026-11-22 21:44:35 +0100
committerDanielDeGiorgio <degiorgiodaniel1808@gmail.com>2026-11-22 21:44:35 +0100
commitddc367d0e30e84984bb8e25e9068bfe43223fadb (patch)
tree06611cfa67a32e9ed3a985e56107226b58ac16e0 /runtime/test/cpp_unwind_test.cpp
parentf847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff)
Keep C++ unwinding enabled in MSVC runtime builds
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}