-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathtest.cpp
More file actions
77 lines (64 loc) · 1.63 KB
/
test.cpp
File metadata and controls
77 lines (64 loc) · 1.63 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
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "stddef.h"
#include <stdexcept>
class ClassA {
~ClassA() noexcept(false) { throw std::exception(); } // NON_COMPLIANT
};
class ClassB {
~ClassB() noexcept(false) // NON_COMPLIANT
try {
throw std::exception();
} catch (...) {
} // Exceptions will be rethrown at the end of the function-try-catch
};
class ClassB2 {
~ClassB2() // COMPLIANT
try {
throw std::exception();
} catch (...) {
return; // Execution doesn't reach end of the function-try-catch, so
} // exception is not rethrown
};
class ClassC {
~ClassC() {} // COMPLIANT
};
class ClassD {
~ClassD() // COMPLIANT - exception does not escape
try {
throw std::exception();
} catch (...) {
return;
}
};
void operator delete(void *ptr) { // NON_COMPLIANT
// NOTE: cannot be declared noexcept(false)
throw std::exception();
}
void operator delete(void *ptr, size_t size) { // NON_COMPLIANT
// NOTE: cannot be declared noexcept(false)
throw std::exception();
}
class ClassE {
ClassE &operator=(ClassE &&rhs) noexcept(true) { return *this; } // COMPLIANT
};
class ClassF {
ClassF &operator=(ClassF &&rhs) noexcept(
false) { // COMPLIANT -not covered by CERT, only AUTOSAR
throw std::exception();
}
};
class ClassG {
ClassG(ClassG &&rhs) noexcept(true) {} // COMPLIANT
};
class ClassH {
ClassH(ClassH &&rhs) noexcept(
false) { // COMPLIANT -not covered by CERT, only AUTOSAR
throw std::exception();
}
};
void swap(ClassA &lhs, ClassA &rhs){
// COMPLIANT
};
void swap(ClassB &lhs, ClassB &rhs) noexcept(
false) { // COMPLIANT -not covered by CERT, only AUTOSAR
throw std::exception();
};