blob: 12bdbb62e7cc6cb285122f9b138769c6c847ef37 [file] [log] [blame]
Louis Dionnee92a9c92019-05-17 14:53:29 +00001//===----------------------------------------------------------------------===//
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
Louis Dionne8c611142020-04-17 10:29:15 -04009// UNSUPPORTED: no-exceptions
Louis Dionnee92a9c92019-05-17 14:53:29 +000010
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
19struct exception {
20 exception() : x(0) { }
Igor Zhukov70248922023-09-08 11:15:53 -040021 exception(const exception&) = default;
22 exception& operator=(const exception&) = default;
Louis Dionnee92a9c92019-05-17 14:53:29 +000023 virtual ~exception() { }
24 int x;
25};
26
27struct foo : exception { };
28
Louis Dionne504bc072020-10-08 13:36:33 -040029int main(int, char**) {
Louis Dionnee92a9c92019-05-17 14:53:29 +000030 try {
31 throw foo();
32 } catch (...) {
33
34 }
35 return 0;
36}