Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)
I have an expression in a program, initial value of i = 10
int j = i++ + i++;
it sets j as 20
but
int j = i++ + ++i;
it sets j as 22
Why is there a difference of two between statements? I think, difference should be of 1.
I know this is undefined in C, but why GCC
is doing such things?