when you have the following in the code, the misra check crashes in the misra_20_9 check #define bad_define #define correct_define 1 #if bad_define printf ("will crash the misra check\n"); #endif #if correct_define printf ("Hello\n"); #endif I managed to fix the code by adding an extra escape in misra.py. This way we don't try to access s[0] after the cond.E.split def misra_20_9(self, cfg): for cond in cfg.preprocessor_if_conditions: if cond.E is (None or u""): continue I found it also strange that...
Issue seems to be fixed now Fix #14086 (simplecpp: Update to 1.5.2) (#7762) https://github.com/danmar/simplecpp/blob/master/simplecpp.cpp Fix infinite loop with circular includes (#497)
Issue seems to be fixed now Fix #14086 (simplecpp: Update to 1.5.2) (#7762)
On 3aug2025 preprocessor and simplecpp got updated, and after this update cppcheck is failing to analyze real projects. In cppcheck/test I added color.h, and that was enough to trigger the problem. color.h includes fixture.h and fixture.h includes color.h again. This is perfectly ok in regular c-code. And the preprocessor of the c-compiler we give a helping hand to protect itself with the ifndef/#define or #pragma once. And before the update, cppcheck also did not have issues with circular includes....
On 3aug2025 preprocessor and simplecpp got updated, and after this update cppcheck is failing to analyze real projects. In cppcheck/test I added color.h, and that was enough to trigger the problem. color.h includes fixture.h and fixture.h includes color.h again. This is perfectly ok in regular c-code. And the preprocessor of the c-compiler we give a helping hand to protect itself with the #ifndef/#define or #pragma once. And before the update, cppcheck also did not have issues with circular includes....
When I try to run the last SCA on my project, it is getting stuck in a header-file. The header-file names array.h contains multiple classes and their implementation. I added some debug options in cppcheck, to see if I can find where in cppcheck it is getting stuck, but without much luck. Also when I look in the dump-file I see the last line is . And tips on how to debug this issue with cppcheck? how I launch cppcheck: cppcheck --enable=warning,style,performance,information,portability --include=macro.h...
I did some time debugging some "syntax error" that SCA was throwing. The annoying thing is that cppcheck stops analysis of the file where it found the syntax error in, and it almost gives no clue where in cppcheck the syntax error was flagged for what reason. In my case the issue was caused by a macro not being defined. And it would have helped me if the error message would not have been so vague. Looking at cppcheck at all the places that can throw a syntax error, I found that Tokeninze.cpp has...
I know that misra is not meant to be used on std::string's, but it is able to detect bad coding practices on cpp-files. So it would be nice to limit the amount of false errors. void misra_9_4 () { std::string std_string_array[5]= {"aaa","bbb","ccc","ddd","eee"};//<-- M.9.4 An element of an object shall not be initialized more than once float arr[5] = { 1.0, 2.0, 3.0, 4.0, 5.0 }; }