Eric Fiselier | c74a2e1 | 2017-03-04 02:04:45 +0000 | [diff] [blame^] | 1 | //===----------------------------------------------------------------------===// |
| 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 | |
| 16 | struct __attribute__((aligned)) AlignedType {}; |
| 17 | struct MinAligned { }; |
| 18 | static_assert(alignof(MinAligned) == 1 && sizeof(MinAligned) == 1, ""); |
| 19 | |
| 20 | int 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 | } |