But it is not conclusive if there is a leak or not. func() may exit. A function call at the end of a scope can often cause bailouts. Put some code after the function call and cppcheck will not assume that it exit. Or do something with the return value of func().
But if the check assumes that func() exits then the --check-library should have warned about this.. but I do not see a warning.
Last edit: Daniel Marjamäki 2019-08-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If I have this code:
Cppcheck correctly detects a memory leak:
However if I add some code to
leak()
Cppcheck no longer detects the leak. Even if this code does not reference variablep
:$ cppcheck --enable=style leak.cc Checking leak.cc ...
Is this a limitation of Cppcheck or is this a bug?
This is with Cppcheck 1.86 on CentOS 7.
I am not sure what happens.
But it is not conclusive if there is a leak or not. func() may exit. A function call at the end of a scope can often cause bailouts. Put some code after the function call and cppcheck will not assume that it exit. Or do something with the return value of func().
But if the check assumes that func() exits then the
--check-library
should have warned about this.. but I do not see a warning.Last edit: Daniel Marjamäki 2019-08-14
I created this trac ticket: https://trac.cppcheck.net/ticket/9279