1 //===------------------------- test_vector3.cpp ---------------------------===// 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 // UNSUPPORTED: libcxxabi-no-exceptions 11 12 #include "cxxabi.h" 13 14 #include <stdio.h> 15 #include <stdlib.h> 16 #include <assert.h> 17 #include <exception> 18 19 #include <memory> 20 21 // use dtors instead of try/catch 22 namespace test1 { 23 struct B { ~Btest1::B24 ~B() { 25 printf("should not be run\n"); 26 exit(10); 27 } 28 }; 29 30 struct A { ~Atest1::A31 ~A() 32 #if __has_feature(cxx_noexcept) 33 noexcept(false) 34 #endif 35 { 36 B b; 37 throw 0; 38 } 39 }; 40 } // test1 41 my_terminate()42void my_terminate() { exit(0); } 43 44 template <class T> destroy(void * v)45void destroy(void* v) 46 { 47 T* t = static_cast<T*>(v); 48 t->~T(); 49 } 50 main()51int main() 52 { 53 std::set_terminate(my_terminate); 54 { 55 typedef test1::A Array[10]; 56 Array a[10]; // calls _cxa_vec_dtor 57 __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>); 58 assert(false); 59 } 60 } 61