As fn1 is a "constant" function pointer (definition is present and not "weak" tagged in the code), the test result will be always true. So, it is probably a "parentheses missing" case. I should have written "if(fn1())".
Why CppCheck doesn't trigger on that ?
I know gcc will (and I suppose CLang too), but with some more simple embedded C compilers, it doesn't ! So, it could be really useful that CppCheck warn about this kind of mistakes.
Do you agree ? 😇
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm a little surprised to get a new error about static storage, given that I checked "style" and "exhaustive" in the GUI...
But theres is still not warning about the "if" mistake.
Last edit: Pierrick Garnier 4 days ago
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
In the first place, congratulations for this project ! Code analysis tools are really useful for faulty developpers as me. Thanks ! ;)
Despite the suspect conditional test "if(fn1)", the following piece of code doesn't trigger any result with cppcheck v. 2.22.0 :
As fn1 is a "constant" function pointer (definition is present and not "weak" tagged in the code), the test result will be always true. So, it is probably a "parentheses missing" case. I should have written "if(fn1())".
Why CppCheck doesn't trigger on that ?
I know gcc will (and I suppose CLang too), but with some more simple embedded C compilers, it doesn't ! So, it could be really useful that CppCheck warn about this kind of mistakes.
Do you agree ? 😇
Are you passing
--enable=styleor--enable=all?Hello,
Thanks a lot for your answer. 👍
I was using the GUI, but using CLI, I've got that :
I'm a little surprised to get a new error about static storage, given that I checked "style" and "exhaustive" in the GUI...
But theres is still not warning about the "if" mistake.
Last edit: Pierrick Garnier 4 days ago
Can you try current head? It looks like this was fixed recently (https://github.com/cppcheck-opensource/cppcheck/commit/2c6098ded748110d507ae23d6a2ea2b56da130bb)
Last edit: CHR 4 days ago
OMG !
You're totally right ! 🤩
I downloaded the last succesful nightly build and there is the result :
Sorry for the "false positive" bug report... 😅
Please accept my best gratitude for the help you gave me, CHR.
This topic can be closed, I think.