Division of int x80000000 by -1 X86 Solaris throws exception

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 1.1.2
    • Affects Version/s: 1.1.2
    • Component/s: vm-legacy
    • None
    • jit
    • b01
    • other
    • solaris_9
    • Verified

      While investigating floating point execption in 4025466 and dup 1264851 I found that the JIT gets around this by throwing a Arithmetic / zero exception. The Java spec states that no exception should be throw. The tests which core in the interpreted version fail using the jit.

      From the spec.

      There is one special case that does not satisfy this rule: if the dividend
      is the negative integer of largest possible magnitude for its type, and the
      divisor is -1, then integer overflow occurs and the result is equal to the
      dividend. Despite the overflow, no exception is thrown in this case.

      It works this way for solaris sparc but not solaris intel.

      vm/instr/irem/irem001/irem00101/irem00101.html fails because of this bug.

      // class to test div by -1 on x86
      final class DivTest
      {
              int i = 0x80000000;
      int j = -1;

              public DivTest()
              {
                      System.out.println("i / j");
                      System.out.println(i / j);
              }
              public static void main(String[] args)
              {
                      new DivTest();
              }
      }

      java.lang.ArithmeticException: / by zero
              at divneg.main(Compiled Code)

            Assignee:
            Steve Dever (Inactive)
            Reporter:
            Bren Caperon (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: