Using cppcheck 2.18, the following code snippet will raise nullPointerRedundantCheck even if it shouldn't.
nullPointerRedundantCheck
#include <stdlib.h> [[noreturn]] void bar(const char *format, ...) __attribute__((format(printf, 1, 2))); int foo(char* location) { if (location == nullptr) { bar(""); } return strtol(location, nullptr, 10); }
cppcheck --enable=warning test.cpp
test.cpp:13:16: warning: Either the condition 'location==nullptr' is redundant or there is possible null pointer dereference: location. [nullPointerRedundantCheck] return strtol(location, nullptr, 10); ^ test.cpp:9:15: note: Assuming that condition 'location==nullptr' is not redundant if (location == nullptr) ^ test.cpp:13:16: note: Null pointer dereference return strtol(location, nullptr, 10); ^
This seems related to the following issue that should have been fixed in 2023: https://sourceforge.net/p/cppcheck/discussion/general/thread/02fab2bec8/
Please let me know if any information is missing!
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14181
Log in to post a comment.
Using cppcheck 2.18, the following code snippet will raise
nullPointerRedundantCheckeven if it shouldn't.cppcheck --enable=warning test.cppThis seems related to the following issue that should have been fixed in 2023: https://sourceforge.net/p/cppcheck/discussion/general/thread/02fab2bec8/
Please let me know if any information is missing!
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14181