Skip to content

Commit e92a9c9

Browse files
committed
[libcxxabi] Add a test for invalid assumptions on the alignment of exceptions
rdar://problem/49864414 llvm-svn: 361039
1 parent 279314e commit e92a9c9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: libcxxabi-no-exceptions
10+
11+
// This test checks that the compiler does not make incorrect assumptions
12+
// about the alignment of the exception (only in that specific case, of
13+
// course).
14+
//
15+
// There was a bug where Clang would emit a call to memset assuming a 16-byte
16+
// aligned exception even when back-deploying to older Darwin systems where
17+
// exceptions are 8-byte aligned, which caused a segfault on those systems.
18+
19+
struct exception {
20+
exception() : x(0) { }
21+
virtual ~exception() { }
22+
int x;
23+
};
24+
25+
struct foo : exception { };
26+
27+
int main() {
28+
try {
29+
throw foo();
30+
} catch (...) {
31+
32+
}
33+
return 0;
34+
}

0 commit comments

Comments
 (0)