facebook / facebook/infer

False Positive: INFINITE_EXECUTION_TIME incorrectly reported for simple terminating while-loop

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

Description

**Description**
Infer incorrectly reports an "Infinite Execution Time" error for a simple while-loop that clearly terminates after a single iteration.

```java
// Case 1
public class TestInferBug1 {
public static void main(String[] args) {
int i = 0;
while (i != 3) {// <- should not report(False Positive)
i += 3;
}
}
}

// Case 2
public class TestInferBug2 {
public static void main(String[] args) {
int i = 0;
while (i != 1) {
i += 1; // True Negative
}
}
}
```
**Expected behavior:**

Case 1: Should NOT report INFINITE_EXECUTION_TIME because:

i starts at 0

First iteration: i != 3 is true, i becomes 3

Second iteration: i != 3 is false, loop terminates

Total: Exactly 1 iteration, not infinite

Case 2: Should correctly not report INFINITE_EXECUTION_TIME (current correct behavior)

**Actual behavior:**

Case 1: INFINITE_EXECUTION_TIME error is incorrectly reported (False Positive)

Case 2: No issue reported (Correct behavior)

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.