C++: Add 'cpp/use-of-unique-pointer-after-lifetime-ends' FP.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-05-22 12:33:34 +01:00
parent 8119a27540
commit 91f860ba4f
2 changed files with 9 additions and 0 deletions

View File

@@ -9,3 +9,4 @@
| test.cpp:177:16:177:16 | call to operator* | The underlying unique pointer object is destroyed after the call to 'operator*' returns. |
| test.cpp:177:36:177:36 | call to operator* | The underlying unique pointer object is destroyed after the call to 'operator*' returns. |
| test.cpp:179:11:179:11 | call to operator* | The underlying unique pointer object is destroyed after the call to 'operator*' returns. |
| test.cpp:209:29:209:31 | call to get | The underlying unique pointer object is destroyed after the call to 'get' returns. |

View File

@@ -203,4 +203,12 @@ void test2(bool b1, bool b2) {
auto s11 = b2 ? nullptr : sRefRef.get(); // GOOD
const S* s12;
s12 = sRefRef.get(); // GOOD
}
void test_convert_to_bool() {
bool b = get_unique_ptr().get(); // GOOD [FALSE POSITIVE]
if(get_unique_ptr().get()) { // GOOD
}
}