brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 12bdbb6 Raw
37 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// This test checks that the compiler does not make incorrect assumptions12// about the alignment of the exception (only in that specific case, of13// course).14//15// There was a bug where Clang would emit a call to memset assuming a 16-byte16// aligned exception even when back-deploying to older Darwin systems where17// exceptions are 8-byte aligned, which caused a segfault on those systems.18 19struct exception {20    exception() : x(0) { }21    exception(const exception&) = default;22    exception& operator=(const exception&) = default;23    virtual ~exception() { }24    int x;25};26 27struct foo : exception { };28 29int main(int, char**) {30    try {31      throw foo();32    } catch (...) {33 34    }35    return 0;36}37