Skip to content

Instantly share code, notes, and snippets.

@galak-fyyar
Created October 13, 2011 18:59
Show Gist options
  • Save galak-fyyar/1285158 to your computer and use it in GitHub Desktop.
Save galak-fyyar/1285158 to your computer and use it in GitHub Desktop.
Weird bug in Java(TM) SE Runtime Environment (build 1.6.0_27-b07) Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)
import java.util.*;
class ForBug {
public static void main( String[] a ) {
int m = Integer.MAX_VALUE;
for ( int n = 1; n <= m; n++ ) {
System.out.println( "Step " + n );
}
}
}
@galak-fyyar
Copy link
Author

For loop in this snippet will end at n == 15588, which obviously not greater that Integer.MAX_VALUE. Looks like it is bug of x64 version only or build. At least on x32 of same version everything works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment