diff options
| author | Nolan Cotter <186326284+NolanCotter@users.noreply.github.com> | 2026-11-22 20:39:59 -0700 |
|---|---|---|
| committer | Nolan Cotter <186326284+NolanCotter@users.noreply.github.com> | 2026-11-22 20:39:59 -0700 |
| commit | fa5f26db8eafd2cc27f627b68c0a5a5949bcf2ff (patch) | |
| tree | fc57e238be829295fc216dff89a6d93e64c16b50 /runtime/test/cpp_unwind_test.cpp | |
| parent | 9b693ecd8a2f90799f6c47f8f06cf062feb9820c (diff) | |
| parent | 7b7d73f890f9fbbf5967bbb694390bbc99e33ba6 (diff) | |
Merge origin/main: DXGI device fields coexist with the console-ABI device state
Diffstat (limited to 'runtime/test/cpp_unwind_test.cpp')
| -rw-r--r-- | runtime/test/cpp_unwind_test.cpp | 31 |
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 | |||
| 3 | namespace { | ||
| 4 | |||
| 5 | struct UnwindMarker { | ||
| 6 | bool& destroyed; | ||
| 7 | ~UnwindMarker() { destroyed = true; } | ||
| 8 | }; | ||
| 9 | |||
| 10 | struct 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 | |||
| 20 | int 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 | } | ||