-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
I discovered an inconsistency in the EXPENSIVE_LOOP_INVARIANT_CALL
detector. In the following code example, Infer reports a warning of this type at line 22, but no warnings at line 23, despite both lines being semantically equivalent. This indicates an inconsistent bug in the detection logic.
import java.util.ArrayList;
public class Main {
int incr(int x) {
return x + 1;
}
void foo1(ArrayList<Integer> list) {
int x = 0;
for (Integer elem : list) {
incr(x);
}
}
void foo2(ArrayList<Integer> list) {
int x = 0;
list.forEach(elem -> incr(x));
}
void func(int size, ArrayList<Integer> list) {
for (int i = 0; i < size; i++) {
foo1(list); // report an EXPENSIVE_LOOP_INVARIANT_CALL warning
foo2(list); // report no warnigns
}
}
}
Metadata
Metadata
Assignees
Labels
No labels