Index: src/cxa_exception.hpp =================================================================== --- src/cxa_exception.hpp +++ src/cxa_exception.hpp @@ -61,7 +61,7 @@ size_t referenceCount; #endif - _Unwind_Exception unwindHeader; + _Unwind_Exception unwindHeader __attribute__((aligned)); }; // http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html @@ -96,7 +96,7 @@ void* primaryException; #endif - _Unwind_Exception unwindHeader; + _Unwind_Exception unwindHeader __attribute__((aligned)); }; struct _LIBCXXABI_HIDDEN __cxa_eh_globals { Index: test/exception_object_alignment.sh.cpp =================================================================== --- /dev/null +++ test/exception_object_alignment.sh.cpp @@ -0,0 +1,46 @@ +//===---------------- exception_object_alignment.sh.cpp -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: libcxxabi-no-exceptions + +// RUN: %cxx %flags %compile_flags -O1 %s -o %t.exe +// RUN: %exec %t.exe + +// This test used to segfault on Darwin because field unwindHeader of struct +// __cxa_exception was not 16B aligned. + +namespace { + +struct S { + int a; + int __attribute__((aligned(16))) b; +}; + +class base1 { +protected: + virtual ~base1() throw() {} +}; + +class derived: public base1 { +public: + derived() : member() {} +private: + S member; +}; + +} + +int main() { + try { + throw derived(); + } + catch(...) { + } + return 0; +}