diff options
author | Louis Dionne <ldionne@apple.com> | 2019-05-17 14:53:29 +0000 |
---|---|---|
committer | Louis Dionne <ldionne@apple.com> | 2019-05-17 14:53:29 +0000 |
commit | e92a9c99d66d6a23bcd15b9bdf5ff8d02406446a (patch) | |
tree | cc0844165f29b31a603d6f8be0ff7eb583a104b8 /libcxxabi | |
parent | 279314e81b5efc5bb2dd41439de8fa9ea36b1859 (diff) | |
download | llvm-e92a9c99d66d6a23bcd15b9bdf5ff8d02406446a.zip llvm-e92a9c99d66d6a23bcd15b9bdf5ff8d02406446a.tar.gz llvm-e92a9c99d66d6a23bcd15b9bdf5ff8d02406446a.tar.bz2 |
[libcxxabi] Add a test for invalid assumptions on the alignment of exceptions
rdar://problem/49864414
llvm-svn: 361039
Diffstat (limited to 'libcxxabi')
-rw-r--r-- | libcxxabi/test/exception_object_alignment.2.pass.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libcxxabi/test/exception_object_alignment.2.pass.cpp b/libcxxabi/test/exception_object_alignment.2.pass.cpp new file mode 100644 index 0000000..33f0f9e --- /dev/null +++ b/libcxxabi/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: libcxxabi-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; +} |