-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8u72
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [versão 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The order of precedence of operators is not being respected when used on a statement with multiplication. For the case in question, ++expr is being evaluated before expr++. However, expr++ has higher precedence over ++expr (https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
assign to a int variable (x) the value 10;
assign to a int variable (y) the value x++ * ++x * x++;
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
y = 10 * 13 * 11
y = 1430
ACTUAL -
y = 1440
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
int x = 10;
int y = x++ * ++x * x++;
System.out.println(y);
}
---------- END SOURCE ----------
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [versão 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The order of precedence of operators is not being respected when used on a statement with multiplication. For the case in question, ++expr is being evaluated before expr++. However, expr++ has higher precedence over ++expr (https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
assign to a int variable (x) the value 10;
assign to a int variable (y) the value x++ * ++x * x++;
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
y = 10 * 13 * 11
y = 1430
ACTUAL -
y = 1440
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
int x = 10;
int y = x++ * ++x * x++;
System.out.println(y);
}
---------- END SOURCE ----------