I’m investigating memory-related issues involving C++ smart pointers (std::unique_ptr, std::shared_ptr) and would like to know if Cppcheck is capable of detecting bugs such as:
Null dereference
Use-after-move
Double deletion or invalid memory access through smart pointers
Does Cppcheck support detection of these patterns? If so, are there specific flags, configuration options, or coding practices that help Cppcheck better identify such issues? Sample code or documentation references would be very helpful.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I’m investigating memory-related issues involving C++ smart pointers (std::unique_ptr, std::shared_ptr) and would like to know if Cppcheck is capable of detecting bugs such as:
Null dereference
Use-after-move
Double deletion or invalid memory access through smart pointers
Does Cppcheck support detection of these patterns? If so, are there specific flags, configuration options, or coding practices that help Cppcheck better identify such issues? Sample code or documentation references would be very helpful.
Nullptr dereference has some issues: https://trac.cppcheck.net/ticket/12868
This is detected though:
Use-after-move should be detected with
--enable=warning
.Double deletion or invalid memory access is probably not implemented. This is not detected:
Last edit: CHR 7 days ago