Both of your cases are undefined, as the C standard does specifically says [something like] "no variable must be updated twice within the same sequence point". Since a sequence point is roughly the same as a statement [there are places where it isn't, but we'll ignore that for now], your
Code:
k = i++ - i++;
breaks that rule.

What actually happens is that the compiler will order the increement of i and subtract independently of each other, which means that it may do:
Code:
k = i - i;
i++;
i++;
or
Code:
i++;
k = i (i++;) - i;   // Not C syntax! It does i++ after taking the first value of i.
And likewise for the ++i variant.

Finally, in theory, the compiler is perfectly allowed to come up with ANY numeric answer - the fact that you are getting some sort of reasonable answer is entirely based on the compiler doing "something sensible", but it's not guaranteed to do that.

--
Mats