A quiz from class has int i = 3; i = i++ + ++i; and asks for the final value of i. Two compilers give me two different values, and with warnings enabled GCC says the operation on i may be undefined. A similar line, printf("%d %d\n", i++, i++);, also prints different numbers on different machines.
I expected the operators to be applied left to right according to precedence. Why is there no single correct answer, and how do I know which expressions are safe?




