Hi,
I found (probably) false positive, when cpp_check thinks it can predict variable value to zero, so the for loop can be removed at all. The simplest program is:
Your online demo says : Cppcheck 2.10 [test.cpp:8]: (style) Condition 'iDone!
Cppcheck 2.11 on my project says:
style: Condition 'i<dsize' is="" always="" false="" <span="">[knownConditionTrueFalse]
note: Assignment 'dsize = (size>32)?32:size', assigned value is less than 1</dsize'>
I think nothing can be predicted, because the function is not static, so it can be called from anywhere with any parameters. Or did I miss something?
Best Regards Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I found (probably) false positive, when cpp_check thinks it can predict variable value to zero, so the for loop can be removed at all. The simplest program is:
Your online demo says : Cppcheck 2.10 [test.cpp:8]: (style) Condition 'iDone!
Cppcheck 2.11 on my project says:
style: Condition 'i<dsize' is="" always="" false="" <span="">[knownConditionTrueFalse] note: Assignment 'dsize = (size>32)?32:size', assigned value is less than 1</dsize'>
I think nothing can be predicted, because the function is not static, so it can be called from anywhere with any parameters. Or did I miss something?
Best Regards Martin
I think this is related to https://trac.cppcheck.net/ticket/11437
@CHR : Yes, it looks like the same problem.