1e92a9c99SLouis Dionne //===----------------------------------------------------------------------===// 2e92a9c99SLouis Dionne // 3e92a9c99SLouis Dionne // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4e92a9c99SLouis Dionne // See https://llvm.org/LICENSE.txt for license information. 5e92a9c99SLouis Dionne // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e92a9c99SLouis Dionne // 7e92a9c99SLouis Dionne //===----------------------------------------------------------------------===// 8e92a9c99SLouis Dionne 98c61114cSLouis Dionne // UNSUPPORTED: no-exceptions 10e92a9c99SLouis Dionne 11e92a9c99SLouis Dionne // This test checks that the compiler does not make incorrect assumptions 12e92a9c99SLouis Dionne // about the alignment of the exception (only in that specific case, of 13e92a9c99SLouis Dionne // course). 14e92a9c99SLouis Dionne // 15e92a9c99SLouis Dionne // There was a bug where Clang would emit a call to memset assuming a 16-byte 16e92a9c99SLouis Dionne // aligned exception even when back-deploying to older Darwin systems where 17e92a9c99SLouis Dionne // exceptions are 8-byte aligned, which caused a segfault on those systems. 18e92a9c99SLouis Dionne 19e92a9c99SLouis Dionne struct exception { exceptionexception20e92a9c99SLouis Dionne exception() : x(0) { } 21*70248920SIgor Zhukov exception(const exception&) = default; 22*70248920SIgor Zhukov exception& operator=(const exception&) = default; ~exceptionexception23e92a9c99SLouis Dionne virtual ~exception() { } 24e92a9c99SLouis Dionne int x; 25e92a9c99SLouis Dionne }; 26e92a9c99SLouis Dionne 27e92a9c99SLouis Dionne struct foo : exception { }; 28e92a9c99SLouis Dionne main(int,char **)29504bc07dSLouis Dionneint main(int, char**) { 30e92a9c99SLouis Dionne try { 31e92a9c99SLouis Dionne throw foo(); 32e92a9c99SLouis Dionne } catch (...) { 33e92a9c99SLouis Dionne 34e92a9c99SLouis Dionne } 35e92a9c99SLouis Dionne return 0; 36e92a9c99SLouis Dionne } 37