The results are undefined. You change a variable more than once in an expression (or a sequence point to be more precise).
Changing a variable more than once between points in a sequence is undefined, so don't do this.
Perhaps this is your compiler, as this particular case solves ++i + ++i as
- add the last
++i , getting 4, leaving me equal to 4 - add the first
++i , getting 5, leaving me equal to 5 (since the previous step I left as 4, increasing it to 5) - sum two values, 4 + 5.
Another compiler, or if you change the optimization level, or slightly change the code, a different conclusion may arise.
source share