In C, most binary operators do not specify which operand will be evaluated first:
int x(void) { putchar('x'); return 10;}int y(void) { putchar('y'); return 10;}// ...x()+y(); // Unspecified behavior as this may print xy or yx
Many other languages make guarantees that the operands will be evaluated left to right, so the equivalent code in Java is guaranteed to print: xy
Leaving things like these unspecified in C is often done for optimization reasons, so are there any optimizations possible for the compiler to perform when sequence points are not defined between operators such as +
=
and similar?