summaryrefslogtreecommitdiff
path: root/current/sources/cxx-stl/llvm-libc++abi/test/exception_object_alignment.2.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'current/sources/cxx-stl/llvm-libc++abi/test/exception_object_alignment.2.pass.cpp')
-rw-r--r--current/sources/cxx-stl/llvm-libc++abi/test/exception_object_alignment.2.pass.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/current/sources/cxx-stl/llvm-libc++abi/test/exception_object_alignment.2.pass.cpp b/current/sources/cxx-stl/llvm-libc++abi/test/exception_object_alignment.2.pass.cpp
new file mode 100644
index 000000000..b35e72862
--- /dev/null
+++ b/current/sources/cxx-stl/llvm-libc++abi/test/exception_object_alignment.2.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: no-exceptions
+
+// This test checks that the compiler does not make incorrect assumptions
+// about the alignment of the exception (only in that specific case, of
+// course).
+//
+// There was a bug where Clang would emit a call to memset assuming a 16-byte
+// aligned exception even when back-deploying to older Darwin systems where
+// exceptions are 8-byte aligned, which caused a segfault on those systems.
+
+struct exception {
+ exception() : x(0) { }
+ virtual ~exception() { }
+ int x;
+};
+
+struct foo : exception { };
+
+int main() {
+ try {
+ throw foo();
+ } catch (...) {
+
+ }
+ return 0;
+}