34 lines · cpp
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: no-exceptions10 11// Check that the pointer __cxa_allocate_exception returns is aligned to the12// default alignment for the target architecture.13 14#include <cassert>15#include <cstdint>16#include <cxxabi.h>17#include <type_traits>18#include <__cxxabi_config.h>19 20struct S {21 int a[4];22} __attribute__((aligned));23 24int main(int, char**) {25#if !defined(_LIBCXXABI_ARM_EHABI)26 void *p = __cxxabiv1::__cxa_allocate_exception(16);27 auto i = reinterpret_cast<uintptr_t>(p);28 auto a = std::alignment_of<S>::value;29 assert(i % a == 0);30 __cxxabiv1::__cxa_free_exception(p);31#endif32 return 0;33}34