-
Bug
-
Resolution: Duplicate
-
P3
-
6u14
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)
FULL OS VERSION :
Linux server 2.6.29-gentoo-r5 #3 SMP PREEMPT Sat May 30 18:31:37 CEST 2009 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 4600+ AuthenticAMD GNU/Linux
A DESCRIPTION OF THE PROBLEM :
x is supposed to be identical for both loops. And is if max = Integer.MAX_VALUE-1:
238
2147483646
268
2147483646
But it's not if max=Integer.MAX_VALUE-0:
284
2147483635
205
2147483632
This appears to be a bug in jdk6u14 on amd64 only.
public class Loop
{
public static void main( String[] args )
{
int max = Integer.MAX_VALUE;
long x=0l;
long t0,t1;
t0 = System.currentTimeMillis();
for(int i = 0; i < Math.max( 0,max); i++){
x++;
}
t1 = System.currentTimeMillis();
System.out.println(t1-t0);
System.out.println(x);
x =0;
t0 = System.currentTimeMillis();
for(int i = 0, a = Math.max(0,max); i < a; i++){
x++;
}
t1 = System.currentTimeMillis();
System.out.println(t1-t0);
System.out.println(x);
}
}
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)
FULL OS VERSION :
Linux server 2.6.29-gentoo-r5 #3 SMP PREEMPT Sat May 30 18:31:37 CEST 2009 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 4600+ AuthenticAMD GNU/Linux
A DESCRIPTION OF THE PROBLEM :
x is supposed to be identical for both loops. And is if max = Integer.MAX_VALUE-1:
238
2147483646
268
2147483646
But it's not if max=Integer.MAX_VALUE-0:
284
2147483635
205
2147483632
This appears to be a bug in jdk6u14 on amd64 only.
public class Loop
{
public static void main( String[] args )
{
int max = Integer.MAX_VALUE;
long x=0l;
long t0,t1;
t0 = System.currentTimeMillis();
for(int i = 0; i < Math.max( 0,max); i++){
x++;
}
t1 = System.currentTimeMillis();
System.out.println(t1-t0);
System.out.println(x);
x =0;
t0 = System.currentTimeMillis();
for(int i = 0, a = Math.max(0,max); i < a; i++){
x++;
}
t1 = System.currentTimeMillis();
System.out.println(t1-t0);
System.out.println(x);
}
}
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try
REPRODUCIBILITY :
This bug can be reproduced always.
- duplicates
-
JDK-5091921 Sign flip issues in loop optimizer
-
- Closed
-