0

Here is my .cfg

<?xml version="1.0"?>
<def format="1">
  <function name="wcscpy_s">
        <arg nr="1">
            <not-uninit/>
        </arg>
        <arg nr="2">
            <not-uninit/>
        </arg>
        <arg nr="3">
            <not-uninit/>
        </arg>
    </function>
</def>

And I use it to check blow cpp file.

int main() {
    char a[100];
    wcscpy_s(
        a,
        a,
        a);
}

And the error is:

D:\staff>cppcheck D:\staff\test.cpp --library=my.cfg
Checking D:\staff\test.cpp...
[D:\staff\test.cpp:4]: (error) Uninitialized variable: a
[D:\staff\test.cpp:5]: (error) Uninitialized variable: a

Obviously it not find the third parameter, it is unitialized too. I changed the file to this:

int main() {
    char a[100];
    wcscpy_s(
        1,
        1,
        a);
}

And it not show any error now. So I'm very confused. Cppcheck can't check the third parameters?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Zerochs
  • 3
  • 3

2 Answers2

0

Of course it's not by intention. I think it's caused by some old code that was only meant to handle some special functions.

Can you create a ticket about this? http://trac.cppcheck.net/

Daniel Marjamäki
  • 2,907
  • 15
  • 16
0

The latest version of Cppcheck (1.70 dev) is able to detect this issue:

$ cppcheck test.cpp  --library=my.cfg
Checking test.cpp...
[test.cpp:4]: (error) Uninitialized variable: a
[test.cpp:5]: (error) Uninitialized variable: a
[test.cpp:6]: (error) Uninitialized variable: a
orbitcowboy
  • 1,438
  • 13
  • 25