facebook / facebook/infer

False positive UNINITIALIZED_VALUE in C

Open
#941 1 comment 0 reactions 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

Infer (version v0.15.0) reports an UNINITIALIZED_VALUE when accessing an array item that was initialized:

```
main.c:10: error: UNINITIALIZED_VALUE
The value read from a[_] was never initialized.
8. a[i] = 0;
9. }
10. > printf("%c\n", a[3]);
11. return 0;
12. }
```

Case in point:

```c
#include

int main() {
unsigned len = 7;
char a[len];
unsigned i;
for (i = 0; i < len; ++i) {
a[i] = 65 + i;
}
printf("%c\n", a[3]);
return 0;
}
```

The same is true when `memset(a, 0, len);` is used to initialize `a`.

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.