C++: Add false positive testcase involving conversions.

This commit is contained in:
Mathias Vorreiter Pedersen
2021-05-07 12:19:19 +02:00
parent 88e6cbaacd
commit 7adb7b67f2
2 changed files with 7 additions and 0 deletions

View File

@@ -16,3 +16,4 @@
| test.cpp:151:9:151:24 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:152:15:152:18 | { ... } | This catch block |
| test.cpp:199:15:199:35 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:201:16:201:19 | { ... } | This catch block |
| test.cpp:212:14:212:34 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:213:34:213:36 | { ... } | This catch block |
| test.cpp:225:23:225:29 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:226:34:226:36 | { ... } | This catch block |

View File

@@ -218,4 +218,10 @@ void good_new_catch_exception_in_assignment() {
try {
p = new int; // GOOD
} catch(const std::bad_alloc&) { }
}
void good_new_catch_exception_in_conversion() {
try {
long* p = (long*) new int; // GOOD [FALSE POSITIVE]
} catch(const std::bad_alloc&) { }
}