JDK-5094936 : Compiler generates wrong results (wrong loop optimization)
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 2004-08-31
  • Updated: 2010-12-07
  • Resolved: 2010-12-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
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));
    }
}

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
02-09-2004

EVALUATION Appears to be same as 5091921 BigDecimal.divideAndRemainder()'s loop that ends with: if(i1 <= l1) break; j2--; i1 -= 9; } while(true); exits prematurely when i1: 0 and l1: -2147483648 (0x80000000)
02-09-2004