I see, so I guess ticket 10505 is the main issue. Regarding the namespace the original code above warns, but this one does not: namespace test { class RAII { public: RAII(){} ~RAII(){} }; } int main() { auto raii = test::RAII(); return 0; }
I worked on minimizing it and ended up with this: namespace test { class RAII { public: RAII(){} ~RAII(){} }; } using namespace test; int main() { auto raii = RAII(); return 0; } The problem seem to be the using namespace test; , if I remove that and explicitly use test::RAII() the warning goes away. I ran it like this: cppcheck --std=c++17 --enable=all raii.cpp (The compiler are happy with both versions.) It also reproduces at https://cppcheck.sourceforge.io/demo/
Hi, I am having issues like: style: Variable 'raii' is assigned a value that is never used. [unreadVariable] with our custom raii classes. What information is cppcheck missing such that it would know not to warn for such cases? I did use --check-config to see if there were any missing includes. But it only lists various system includes not from my code. I am using cppcheck 2.7.3.
Thanks, seems related. Subscribed.
I am getting this for cppcheck on sqlite3.c on the following piece of code: #if defined(SQLITE_SYSTEM_MALLOC) \ + defined(SQLITE_WIN32_MALLOC) \ + defined(SQLITE_ZERO_MALLOC) \ + defined(SQLITE_MEMDEBUG)>1 # error "Two or more of the following compile-time configuration options\ are defined but at most one is allowed:\ SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\ SQLITE_ZERO_MALLOC" #endif Specifically the error message points to the 6th line above. Seems it's not taking the line...
Using the suppressions-list file instead seem to work, so I'll use that instead. Still confusing with the different behavior of -i though.
I just posted a related topic https://sourceforge.net/p/cppcheck/discussion/general/thread/94ffb177/ But in there I got the exclusion to work in some environments but not others - so I am rather confused as to what behavior is expected or if it's configurable or something else?
Hi, I have a script that based on different conditions will run cppcheck on a different set of files. However I am struggling with some inconsistent weirdness, when I run the following command: cppcheck -ifile.c file.c With some cppcheck binaries I get the following output cppcheck: error: no files to check - all paths ignored. which is what I expect - I want to be able to ignore files even though they are explicitly listed. But with other cppcheck binaries I get: Checking file.c ... : and it starts...