Hi, I just updated cppcheck to version 2.13.0 (from 1.90), and it does not report any MISRA violations any more. Using this command:
cppcheck --addon=misra misra-test.c
misra-test.c is my custom test file with the following contents:
#include <stdint.h>#include "file//.h"#define TEST 34566lconstchar*s41_1="\x41g";intmain(constintargc,constchar*argv){charc[2][2]={1,2,3,4};intret=10;/*//*/returnret;}
cppcheck version 1.90 reported 5 violations in it, but cppcheck 2.13.0 reports nothing.
The output is (using -v switch):
But with this I'm unable to use the --xml option of cppcheck, which I need.
I have both versions of ccpcheck installed in Docker containers, the 1.90 is in Ubuntu 20.04, the 2.13.0 is in Ubuntu 24.04. Both have python of course. Mentioning this just in case, although I don't know why it could be a problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have just installed version 2.17.1 from the source, and it's still the same. Am I doing something wrong here? If it was a bug I don't suppose it would go unnoticed for so many releases.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
They are style warnings which are not enabled by default. You need to add --enable=style for them to show. That behavior changed in 2.11 (I do not have an exact commit).
Strangely I am only seeing 6 MISRA warnings using the official Windows binaries but I am getting 10 MISRA warnings on Linux. That needs looking into.
It also looks like the performance took a major hit starting with 2.5 or even earlier.
Last edit: Oliver Stöneberg 2025-05-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you sir, this fixed my problem.
No manual or guide I could find mentioned this. Perhaps the official manual deserves an update :)
Regarding the number of found violations, if I call it with just --addon=misra, it will find 7 violations, but when called with --addon=misra-custom.json, where the json file specifies a "rule-texts" file, it will find 10. And all of the new ones are different rules on the same lines as the previously found ones. Also I tried to fix a violation from one line the first output, and then it started detecting the second violation on the same output:
root@27830908bbb7:/work#cppcheck--addon=misra--enable=stylemisra-test.cCheckingmisra-test.c...misra-test.c:5:14:style:misraviolation(use--rule-texts=<file>togetproperoutput)[misra-c2012-7.3]#define TEST 34566l^root@27830908bbb7:/work#cppcheck--addon=misra-custom.json--enable=stylemisra-test.cCheckingmisra-test.c...misra-test.c:5:14:style:Donotuselowercase'l'inconstants[misra-c2012-7.3]#define TEST 34566l^misra-test.c:5:0:style:Avoidunusedmacros[misra-c2012-2.5]#define TEST 34566l^// Now I have changed 34566l to 34566Lroot@27830908bbb7:/work#cppcheck--addon=misra--enable=stylemisra-test.cCheckingmisra-test.c...misra-test.c:5:0:style:misraviolation(use--rule-texts=<file>togetproperoutput)[misra-c2012-2.5]#define TEST 34566L^
So it seems like cppcheck (on Windows) will show max one MISRA violation per line if rule-texts are not provided.
Last edit: Kazimierz Król 2025-05-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I just updated cppcheck to version 2.13.0 (from 1.90), and it does not report any MISRA violations any more. Using this command:
misra-test.c is my custom test file with the following contents:
cppcheck version 1.90 reported 5 violations in it, but cppcheck 2.13.0 reports nothing.
The output is (using -v switch):
Running cppcheck with --dump and then misra.py manually seems to be finding the violations:
But with this I'm unable to use the --xml option of cppcheck, which I need.
I have both versions of ccpcheck installed in Docker containers, the 1.90 is in Ubuntu 20.04, the 2.13.0 is in Ubuntu 24.04. Both have python of course. Mentioning this just in case, although I don't know why it could be a problem.
I have just installed version 2.17.1 from the source, and it's still the same. Am I doing something wrong here? If it was a bug I don't suppose it would go unnoticed for so many releases.
They are
style
warnings which are not enabled by default. You need to add--enable=style
for them to show. That behavior changed in 2.11 (I do not have an exact commit).Strangely I am only seeing 6 MISRA warnings using the official Windows binaries but I am getting 10 MISRA warnings on Linux. That needs looking into.
It also looks like the performance took a major hit starting with 2.5 or even earlier.
Last edit: Oliver Stöneberg 2025-05-09
Thank you sir, this fixed my problem.
No manual or guide I could find mentioned this. Perhaps the official manual deserves an update :)
Regarding the number of found violations, if I call it with just --addon=misra, it will find 7 violations, but when called with --addon=misra-custom.json, where the json file specifies a "rule-texts" file, it will find 10. And all of the new ones are different rules on the same lines as the previously found ones. Also I tried to fix a violation from one line the first output, and then it started detecting the second violation on the same output:
So it seems like cppcheck (on Windows) will show max one MISRA violation per line if rule-texts are not provided.
Last edit: Kazimierz Król 2025-05-13