cppcheck 2.0
1. incorrect locking with mutex - Called std::mutex lock() and unlock() is not invoked. The violation js not detected. std::mutex is supported?
2. Call of pure virtual function in constructor/destructor - is not working .
3. Not taking the address to allocated memory is not reported for statement like new int() ; but reports issue when malloc is used
4. Dangerous usage of strncat() - not reported issue when source and destination buffers overlap.
5. Partial string write that leads to buffer that is not zero terminated -- not reports issue when memcpy is used.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
could you please provide some small test cases. then I will open tickets..
if you want you could create some kind of test suite with various test cases.
If I test out Cppcheck then it will find many bugs I can imagine. It is not optimal when the tester and developer are the same person. So I think a test suite written by you would have interesting variations that I would miss.
Last edit: Daniel Marjamäki 2020-11-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the reply.
I have below queries. incorrect locking with mutex is not detected for below code.
int i = 0;
std::mutex m;
void test()
{
m.lock();
i++;
return;
}
- Call of pure virtual function in constructor/destructor - Is this enabled in 2.0. There was a discussion in tbe forum that issue in 1.9
Last edit: kpk 2020-11-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We do not warn about that. You might unlock the mutex in the function that calls test. Imho it would be a more robust coding style to use a scope lock.
cppcheck 2.0
1. incorrect locking with mutex - Called std::mutex lock() and unlock() is not invoked. The violation js not detected. std::mutex is supported?
2. Call of pure virtual function in constructor/destructor - is not working .
3. Not taking the address to allocated memory is not reported for statement like new int() ; but reports issue when malloc is used
4. Dangerous usage of strncat() - not reported issue when source and destination buffers overlap.
5. Partial string write that leads to buffer that is not zero terminated -- not reports issue when memcpy is used.
Thanks!
could you please provide some small test cases. then I will open tickets..
if you want you could create some kind of test suite with various test cases.
If I test out Cppcheck then it will find many bugs I can imagine. It is not optimal when the tester and developer are the same person. So I think a test suite written by you would have interesting variations that I would miss.
Last edit: Daniel Marjamäki 2020-11-24
Thanks for the reply.
I have below queries. incorrect locking with mutex is not detected for below code.
int i = 0;
std::mutex m;
void test()
{
m.lock();
i++;
return;
}
- Call of pure virtual function in constructor/destructor - Is this enabled in 2.0. There was a discussion in tbe forum that issue in 1.9
Last edit: kpk 2020-11-26
We do not warn about that. You might unlock the mutex in the function that calls test. Imho it would be a more robust coding style to use a scope lock.
We have some checks for std::mutex as you can see in the teststl.cpp file. You can search for "std::mutex" here: https://github.com/danmar/cppcheck/blob/main/test/teststl.cpp
which forum?