facebook / facebook/infer

A false negative about NULL_DEREFERENCE

Open
#1,628 0 comments 0 reactions 0 assignees View on GitHub
false-negative
Dominant language
OCaml
Stars
15.7k
Forks
2.1k
Avg merge
19h 36m
Merged PRs (30d)
13

Description

A very nice and powerful tool! I found an interesting case.

Infer version: 1.1.0
OS version: Ubuntu 20.04
Command:
```shell
infer run --pulse -- javac Test.java
```
Output:
```shell
Capturing in javac mode...
Found 1 source file to analyze in /path/to/infer-out
1/1 [################################################################################] 100% 63.113ms
```
Code example:
```java
enum Color {
BLACK,
WHITE;
}
public class Test {
Color color = null;
public String bad() {
switch (color) {
case BLACK:
return "BLACK";
case WHITE:
return "WHITE";
default:
return "DEFAULT";
}
}
}
```
However, if we move color to `bad()`, we can get NULL_DEREFERENCE warning:
```java
public String bad() {
Color color = null;
switch (color) {
case BLACK:
return "BLACK";
case WHITE:
return "WHITE";
default:
return "DEFAULT";
}
}
```

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.