Hi, I made a test file and tried to figure out how the value flow works. I attached the input file and the output from the cppcheck.
#include<stdio.h>intfunc();voidmain(){intk=0;intj=0;k=func();if(k>0&&k<10){j=k+1;printf("j is %d\n",j);}}
3:intfunc();4:5:voidmain(){6:intk@var1;k@var1=0;7:intj@var2;j@var2=0;8:k@var1=@exprUNIQUEfunc(@exprUNIQUE);9:if(k@var1>@exprUNIQUE0&&@exprUNIQUEk@var1<@exprUNIQUE10){10:j@var2=@exprUNIQUEk@var1+@exprUNIQUE1;11:printf(@exprUNIQUE"j is %d\n"@exprUNIQUE,@exprUNIQUEj@var2);12:}13:}Line6=always00always0Line7=always00always0Line9>always{!<=-1,!>=2}0always0&&always{!<=-1,!>=2}k{>=1,!<=0}<{!<=-1,!>=2,>=1}10always10Line10={>=2,!<=1,<=10,!>=11}k{>=1,!<=0,<=9,!>=10}+{>=2,!<=1,<=10,!>=11}1always1Line11"j is %d\n"always"j is %d\n"j{symbolic=(k+1),>=2,<=10,!<=1,!>=11}
For line 9,
if(k>0&&k<10){
we get the output '> always {!<=-1,!>=2}'. As I understand, that '!<=-1' is output is because 'k > 0' and we have 'int k = 0' at the beginning, but I an not sure if I am right. But why '!>=2' is output?
Thanks a lot!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I made a test file and tried to figure out how the value flow works. I attached the input file and the output from the cppcheck.
For line 9,
we get the output '> always {!<=-1,!>=2}'. As I understand, that '!<=-1' is output is because 'k > 0' and we have 'int k = 0' at the beginning, but I an not sure if I am right. But why '!>=2' is output?
Thanks a lot!
The comparison operator is Boolean, so this
> always {!<=-1,!>=2}
is just the range of possible values.