This
cppcheck --enable=style --inconclusive --check-config --xml --xml-version=2 -v -I.. -I../mocks -I../gmock -I../gtest -DUNIT_TEST ../src
results in this
<?xml version="1.0" encoding="UTF-8"?>
<results version="2">
<cppcheck version="1.52"/>
<errors>
Checking ../src/AppMain.cpp...
</errors>
</results>
Obviously, I am doing something wrong - but what?
Btw, I am certain that the code has problems, but just to be sure, I pasted these two lines into it
char a[10];
a[10] = 0;
And there was no report of referencing out of bounds
Without a minimal working example to reproduce the problem it is hard to help.
First of all, remove the check-config parameter since it does the following:
--check-config Check cppcheck configuration. The normal code analysis is disabled by this flag.
To know the sourcecode is important, because if you define UNIT_TEST and this particular snipet is not active because of this, it wont show any problems.
Furthermore, you should specify "--enable=all" if you want to see errors because out-of-bounds is classified as error, not as style. Unused variable (as given in your example) is a style problem though.
Running cppcheck (v1.72)
cppcheck --enable=all --inconclusive --xml-version=2 -v foo.cpp
on this
void main()
{
char a[10];
a[10] = 0;
}
results in the following output for me
<?xml version="1.0" encoding="UTF-8"?>
<results version="2">
<cppcheck version="1.72"/>
<errors>
<error id="unreadVariable" severity="style" msg="Variable 'a' is assigned a value that is never used." verbose="Variable 'a' is assigned a value that is never used.">
<location file="foo.cpp" line="5"/>
</error>
<error id="arrayIndexOutOfBounds" severity="error" msg="Array 'a[10]' accessed at index 10, which is out of bounds." verbose="Array 'a[10]' accessed at index 10, which is out of bounds.">
<location file="foo.cpp" line="5"/>
</error>
</errors>
</results>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With