A variable never should be increased more than one time within one statement, because the behaviour of the compiler isn't defined.
To avoid side effects, make two statements for your examples.
Example 1: k = i++; k += ++i;
Example 2: k = ++i; k += ++i;
If you do so, your code will work correctly.