Using gcc on x86 (version 4.7.2) I find the following:
a=(++a)%3 gives: 0,1,2,0,1,2,0,....
a=(a++)%3 gives: 1,2,3,1,2,3,1.....
which, to me, was a little surprising. I thought they both would give 0,1,2...
On Arduino with avr-g++ (otherwise the same compiler) I get:
a=(++a)%3 gives: 0,1,2,0,1,2,0,.... same as for x86
a=(a++)%3 gives: 0,1,2,3,4,5,6,7,8,9,10....
which is even more surprising.
Can anyone explain why? Is it because of a difference in gcc and avr-g++, or does it have something to do with the options Arduino provides? I can see it may be due to some optimizing option... but I have tried all the Arduino options on the gcc compiler too and nothing changes.