False Negative : Overflowing int arithmetic assigned to long is missed
Affects errorprone Version:
2.48.0
Checker:
IntLongMath
Description:
The official IntLongMath checker warns when an arithmetic expression is evaluated as int and only widened to long afterward, because overflow can already have happened in the intermediate computation. This sample is exactly that pattern.
Code Sample demonstrating the issue:
public class PosCase1 {
public static void main(String[] args) {
long result = 1000000 * 3000000;
System.out.println(result);
}
}
Both operands are int literals, so the multiplication is performed in int first. 1000000 * 3000000 exceeds Integer.MAX_VALUE, so the overflow happens before the value is assigned to long.
Expected outcome:
Error Prone should report IntLongMath here, but it doesn't. This is a false-negative.