not sure what the right fix is.. if you feel that your code should work fine then maybe you could elaborate a bit and we can try to fix the false positive.
I assume that Cppcheck parser is right to "call" the non-const fct() function by default? If the Cppcheck parser picked the wrong function then obviously we should fix that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
CppCheck warns me (assertWithSideEffect) about this code :
assert(fct());
With fct defined as follow :
int fct() { return 3; }
int fct() const { return 3; }
It seems that CppCheck uses the non-const definition of fct. If I
comment out the non-const definition, the CppCheck warning disappears.
What is the right way to fix this warning ?
Thanks,
not sure what the right fix is.. if you feel that your code should work fine then maybe you could elaborate a bit and we can try to fix the false positive.
I assume that Cppcheck parser is right to "call" the non-const
fct()
function by default? If the Cppcheck parser picked the wrong function then obviously we should fix that.