C++: Add false positive testcase involving assignments.

This commit is contained in:
Mathias Vorreiter Pedersen
2021-05-07 11:48:09 +02:00
parent 08fa611700
commit 80d41d9fe5
2 changed files with 8 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:219:9:219:15 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:220:34:220:36 | { ... } | This catch block |

View File

@@ -212,3 +212,10 @@ void bad_new_catch_baseclass_of_bad_alloc() {
int* p = new(std::nothrow) int; // BAD
} catch(const std::exception&) { }
}
void good_new_catch_exception_in_assignment() {
int* p;
try {
p = new int; // GOOD [FALSE POSITIVE]
} catch(const std::bad_alloc&) { }
}