-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathtest.cpp
More file actions
64 lines (50 loc) · 1.02 KB
/
test.cpp
File metadata and controls
64 lines (50 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <exception>
#include <new>
#include <stdlib.h>
void exit_wrapper() { exit(1); }
void abort_wrapper() { abort(); }
void h1() {}
void h2() {
if (1) {
throw std::bad_alloc();
}
}
void h3() {}
void h4() { exit(1); }
void h5() { abort(); }
void h6() {
if (1) {
throw std::exception();
}
}
void h7() { exit_wrapper(); }
void h8() { abort_wrapper(); }
int a;
void h9() {
if (a == 1) {
throw std::exception();
}
throw std::bad_alloc();
}
void m1() {
std::set_new_handler(h1); // COMPLIANT
}
void m2() {
std::set_new_handler(h2); // COMPLIANT
}
void m3() {
std::set_new_handler(h6); // NON_COMPLIANT
}
void m4() {
std::set_new_handler(h9); // NON_COMPLIANT
}
void m5() {
std::set_terminate(h3); // NON_COMPLIANT
std::set_unexpected(h3); // NON_COMPLIANT
std::set_terminate(h4); // COMPLIANT
std::set_unexpected(h4); // COMPLIANT
std::set_terminate(h5); // COMPLIANT
std::set_unexpected(h5); // COMPLIANT
std::set_terminate(h7); // COMPLIANT
std::set_unexpected(h8); // COMPLIANT
}