I suggest to take another look at improving source code analysis capabilities.
Would you like to help any further with corresponding software development resources?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We normally only warn when we can prove there are bugs.
Unless there is oom malloc will not return NULL. In that small program it's very unlikely there is oom. In larger programs it is hard to prove.
The plan is there will be more noisy analysis in cppcheck 2.x and when that will be used to detect null pointer dereference I believe we would warn for that code. The plan is that next release will be 2.0 but that will not have a null pointer check. Null pointer checking will be added later (no idea when)...
Last edit: Daniel Marjamäki 2020-03-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, here is small example:
int main(void)
{
int * p = malloc(sizeof(int));
}
My question is: why cppcheck warns only about memory leak? There is also potential null pointer dereference.
Thank you
Last edit: arseniy 2020-03-12
Will return value ignorance matter any more in such situations?
Sorry, what do You mean? Yes this is obvious UB, but why cppcheck ignores it?
I suggest to take another look at improving source code analysis capabilities.
Would you like to help any further with corresponding software development resources?
We normally only warn when we can prove there are bugs.
Unless there is oom malloc will not return NULL. In that small program it's very unlikely there is oom. In larger programs it is hard to prove.
The plan is there will be more noisy analysis in cppcheck 2.x and when that will be used to detect null pointer dereference I believe we would warn for that code. The plan is that next release will be 2.0 but that will not have a null pointer check. Null pointer checking will be added later (no idea when)...
Last edit: Daniel Marjamäki 2020-03-14
ok, thanks :)