Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5094936

Compiler generates wrong results (wrong loop optimization)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 7
    • 6
    • hotspot
    • sparc
    • solaris_2.5.1

      Name: ks84122 Date: 08/31/2004


      The hotspot compiler produces wrong results for a test program with a
      simple loop, in interpreted mode the "correct" result emitted as
      0.11111111111111, when the method is compiled, the emitted result
      becomes 1. The problem is reproducible with C2 on Solaris as well
      as Linux X86

      Solaris:
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Server VM (build 1.4.2-b28, mixed mode)

      Linux:
      java version "1.4.2_06-ea"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-ea-b01)
      Java HotSpot(TM) Client VM (build 1.4.2_06-ea-b01, mixed mode)

      test case (reproducible with the latest 1.5 build ):
      cd /java/jle_build/sko/hp/loop_bug
      export CLASSPATH=./:./ArciMath.jar
      java CompilerBug


      (Incident Review ID: 301400)
      ======================================================================

      import be.arci.math.BigDecimal;
      import be.arci.math.MathContext;

      public class CompilerBug
      {
           public static void main(String[] argv)
           {
           junk();
           }

          public static void junk()
          {
              BigDecimal one = BigDecimal.ONE;
              BigDecimal nine = new BigDecimal(9);
              MathContext context = new MathContext(16, MathContext.SCIENTIFIC);
              for (int i = 0; i < 10000000; ++i)
                  System.out.println(one.divide(nine, context));
          }
      }

            kvn Vladimir Kozlov
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: