False Positive in Infer Null Pointer Dereference Detection
- Dominant language
- OCaml
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 19h 36m
- Merged PRs (30d)
- 13
Description
Hi, I used Infer to detect null pointer dereference issues and encountered a false positive. Below is a minimized example where Infer reports an NPD warning at line 6, even though this line is unreachable.
This appears to be a false positive. Let me know if you need further details.
### Code Example
```java
public class Main {
public static void foo() {
List l = Collections.emptyList();
if (!l.isEmpty()) {
Object o = null;
o.toString(); // report a false NPD warning here
}
}
public static void main(String[] args) {
foo();
}
}
```
### Log
```bash
Found 1 source file to analyze in /path/to/infer-out
4/4 [##########################################################################] 100% 175ms
Main.java:137: error: Null Dereference
`o` could be null (null value originating from line 136) and is dereferenced.
135. if (!l.isEmpty()) {
136. Object o = null;
137. > o.toString();
138. }
139. }
```
### Version
Infer version v1.2.0 MacOS
Contributor guide
Assessment
This issue has not been assessed yet.