JDK-6980767 : Compiler goofs with for loop
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 6u21
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2010-08-28
  • Updated: 2012-03-20
  • Resolved: 2010-12-02
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

Also tested with 1.6.0_21 same behavior

ADDITIONAL OS VERSION INFORMATION :
Linux anugent 2.6.32-24-generic #42-Ubuntu SMP Fri Aug 20 14:21:58 UTC 2010 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
The following loop of code should continue to print out data indefinitely as the int overflows in the foor loop, except it only prints 3 lines when compiled on linux with above mentioned Sun/Oracle JDK. The class file when copied to MacOSX does the same thing there, but when compiled on the mac does not exhibit the same issue.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the attached code,
Run it.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect the system to keep print lines of text, as the integer overflows
ACTUAL -
System prints 3 lines of info. never executes the loop.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

public class JavaBug {
	public static void main(String[] args) {
		System.out.println(System.getProperty("java.runtime.version"));
		int foobar = 2147483647;
		for (int value = 0; value <= foobar; value++)
		{
			if (value % 100000000 == 0) {
				System.out.println("At "+value);
			}
		}
		System.out.println("DONE");
	}
}

---------- END SOURCE ----------