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?

3
  • Oh my god, who thought it's a good idea to describe C++ functions using XML? Commented Feb 3, 2015 at 8:54
  • it's imo great that Cppcheck knows how functions work. xml is a format that has quite good tool support. Commented Feb 3, 2015 at 19:22
  • I think you agree it's good Cppcheck knows how functions work. So how could we configure how wcscpy_s work. I don't think there are many alternatives. Commented Feb 4, 2015 at 5:31

2 Answers 2

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/

Sign up to request clarification or add additional context in comments.

Comments

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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.