Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: 3.1.4
-
Component/s: Compiler: Baseline
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
Quoth the VM spec concerning idiv:
"There is one special case that does not satisfy this rule: if the dividend is the negative integer of largest possible magnitude for the int type, and the divisor is -1, then overflow occurs, and the result is equal to the dividend. Despite the overflow, no exception is thrown in this case."
The included test case will divide its two arguments and print the result. For example:
[pizlo@dethklok test] java intdiv 6 3
2
Note the special case referred to by the VM spec:
[pizlo@dethklok test] java intdiv -2147483648 -1
-2147483648
But the RVM does not handle this correctly:
[pizlo@dethklok test] ~/Programs/RVM-trunk1/dist/FastAdaptiveGenMS_x86_64-linux/rvm intdiv -2147483648 -1
Exception in thread "MainThread" java.lang.ArithmeticException
at intdiv.main(intdiv.java:3)
It's clear that baseline is affected but opt is probably affected, too. It's likely that there are other such corner cases (for example for other types) that we're not handling correctly, either.
Issue Links
- is depended upon by
-
RVM-929
Follow Java Virtual Machine Specification
-
bulk defer open issues to 3.1.2