summaryrefslogtreecommitdiff
path: root/libcxxabi/test/exception_object_alignment.2.pass.cpp
blob: 1afa36e9109b16a2e38f86d3ea1e2c5ba79c3874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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(int, char**) {
    try {
      throw foo();
    } catch (...) {

    }
    return 0;
}