summaryrefslogtreecommitdiff
path: root/test/exception_object_alignment.sh.cpp
blob: 5f4aea2bf8d58319063ddf95d69f67f6445ff5e4 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//===---------------- exception_object_alignment.sh.cpp -------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: libcxxabi-no-exceptions

// RUN: %build -O1
// RUN: %run

// This test used to fail on Darwin because field unwindHeader of struct
// __cxa_exception and the exception object that immediately followed were not
// 16B aligned. It would segfault in class derived's constructor when a movaps
// tried to write to a memory operand that was not 16B aligned.

namespace {

struct S {
  int a;
  int __attribute__((aligned(16))) b;
};

class base1 {
protected:
  virtual ~base1() throw() {}
};

class derived: public base1 {
public:
  derived() : member() {}
private:
  S member;
};

}

int main() {
  try {
    throw derived();
  }
  catch(...) {
  }
  return 0;
}