jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • RVM
  • RVM-824

integer division doesn't follow VM spec

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: 3.1.3
  • Component/s: Compiler: Baseline
  • Labels:
    None
  • Testcase included:
    yes

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.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    intdiv.java
    14/May/09 7:23 PM
    0.2 kB
    Filip Pizlo

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
David Grove added a comment - 04/Jul/10 1:26 PM

bulk defer open issues to 3.1.2

Show
David Grove added a comment - 04/Jul/10 1:26 PM bulk defer open issues to 3.1.2
Hide
Permalink
David Grove added a comment - 22/Dec/11 5:47 AM

Bulk defer to 3.1.3; not essential to address for 3.1.2.

Show
David Grove added a comment - 22/Dec/11 5:47 AM Bulk defer to 3.1.3; not essential to address for 3.1.2.

People

  • Assignee:
    Unassigned
    Reporter:
    Filip Pizlo
Vote (0)
Watch (0)

Dates

  • Created:
    14/May/09 7:23 PM
    Updated:
    22/Dec/11 5:47 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.