Name: swC45995 Date: 01/29/97
jvm aborts when integer remainder operation results in overflow
though JLS says:
The remainder operation for operands that are integers after binary numeric
promotion produces a result value such that (a / b) * b + (a % b) is equal
to a. This identity holds even in the special case that the dividend is the
negative integer of largest possible magnitude for its type and the divisor
is -1 (the remainder is 0). (#15.16.3)
Nevertheless execution of the following test
import java.io.PrintStream;
public class test
{
public static void main(String args[]) {
int i = 0x80000000;
if (i % - 1 != 0)
System.out.println("fail");
else
System.out.println("pass");
}
}
aborts instead of producing correct output which is:
pass
======================================================================
- duplicates
-
JDK-4025466 integer division overflow causes VM crash on Solaris x86
- Closed