blob: 5c5b4dfe7cca8ef1e2e9a1d24d2232f0fa18aba4 [file] [log] [blame]
Eric Fiselierc74a2e12017-03-04 02:04:45 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// Test that the address of the exception object is properly aligned to the
11// largest supported alignment for the system.
12
13#include <cstdint>
14#include <cassert>
15
16struct __attribute__((aligned)) AlignedType {};
17struct MinAligned { };
18static_assert(alignof(MinAligned) == 1 && sizeof(MinAligned) == 1, "");
19
20int main() {
21 for (int i=0; i < 10; ++i) {
22 try {
23 throw MinAligned{};
24 } catch (MinAligned const& ref) {
25 assert(reinterpret_cast<uintptr_t>(&ref) % alignof(AlignedType) == 0);
26 }
27 }
28}