Closed YizhuoZhai closed 2 years ago
Hi @YizhuoZhai, thanks for your report.
caller
does read arg
and passes its value to callee
, even if callee
doesn't use it. Looking at the produced llvm we see that the uninitialised value that %1
points to is loaded: https://godbolt.org/z/ohYqYMMdEp
is only ok if arg1 && arg2
so the function will have a bug in any other case.$ cat issue1612.c
void callee(int *arg) {
*arg++; //Should have an uninitialized use warning here.
}
void caller() {
int arg;
callee(&arg);
arg++; //Should have another uninitialized use warning here.
}
$ infer --pulse-only -- clang -c ~/tmp/issue1612.c
[...]
issue1612.c:6: error: Uninitialized Value
`arg` is read without initialization during the call to `callee()`.
4. void caller() {
5. int arg;
6. callee(&arg);
^
7. arg++; //Should have another uninitialized use warning here.
8. }
Hi, I'm trying the INFER on some small pieces of code, but seems infer does not give the correct answer.
test2.c:2: error: Dead Store The value written to &arg (type int*) is never used.
Found 1 issue Issue Type(ISSUED_TYPE_ID): # Dead Store(DEAD_STORE): 1