facebook / facebook/infer

UNINITIALIZED_VALUE - false positive C

Open
#974 2 comments 1 reaction 0 assignees View on GitHub
c false-positive
Dominant language
OCaml
Stars
15.7k
Forks
2.1k
Avg merge
19h 36m
Merged PRs (30d)
13

Description

In the following minimal example, the `var` variable is initialized into a `while(true)`, however, Infer reports an UNINITIALIZED_VALUE. I checked this case with `if (true)`, `for ( ; ; )` and `while(1)` and Infer returns the same error.
```
int main(){
int var;
while(true){
var = 0;
if(var==0) break;
}
printf("Var:%d\n",var);
return 0;
}
```
This is the Infer's report:
```
Found 1 issue

while_true.c:12: error: UNINITIALIZED_VALUE
The value read from var was never initialized.
10. if(var==0) break;
11. }
12. > printf("Var:%d\n",var);
13. return 0;
14. }

Summary of the reports

UNINITIALIZED_VALUE: 1
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.