Marshall Clow | 280ddee | 2011-06-10 03:40:19 +0000 | [diff] [blame^] | 1 | #include "cxxabi.h" |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <assert.h> |
| 5 | #include <exception> |
| 6 | |
| 7 | #include <memory> |
| 8 | |
| 9 | // use dtors instead of try/catch |
| 10 | namespace test1 { |
| 11 | struct B { |
| 12 | ~B() { |
| 13 | printf("should not be run\n"); |
| 14 | exit(10); |
| 15 | } |
| 16 | }; |
| 17 | |
| 18 | struct A { |
| 19 | ~A() |
| 20 | #if __has_feature(cxx_noexcept) |
| 21 | noexcept(false) |
| 22 | #endif |
| 23 | { |
| 24 | B b; |
| 25 | throw 0; |
| 26 | } |
| 27 | }; |
| 28 | } // test1 |
| 29 | |
| 30 | void my_terminate() { exit(0); } |
| 31 | |
| 32 | template <class T> |
| 33 | void destroy(void* v) |
| 34 | { |
| 35 | T* t = static_cast<T*>(v); |
| 36 | t->~T(); |
| 37 | } |
| 38 | |
| 39 | int main( int argc, char *argv []) |
| 40 | { |
| 41 | std::set_terminate(my_terminate); |
| 42 | { |
| 43 | typedef test1::A Array[10]; |
| 44 | Array a[10]; // calls _cxa_vec_dtor |
| 45 | __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>); |
| 46 | assert(false); |
| 47 | } |
| 48 | } |