llvm-project
37 строк · 950.0 Байт
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-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03
10// REQUIRES: no-exceptions
11
12#include <cxxabi.h>
13#include <exception>
14#include <cassert>
15#include <stdlib.h>
16
17// namespace __cxxabiv1 {
18// void __cxa_rethrow_primary_exception(void* thrown_object);
19// }
20
21unsigned gCounter = 0;
22
23void my_terminate() { exit(0); }
24
25int main ()
26{
27// should not call std::terminate()
28__cxxabiv1::__cxa_rethrow_primary_exception(nullptr);
29
30std::set_terminate(my_terminate);
31
32// should call std::terminate()
33__cxxabiv1::__cxa_rethrow_primary_exception((void*) &gCounter);
34assert(false);
35
36return 0;
37}
38