Quote:
So the output should be a=7 and b=15. But it is not.
Obviously, your compiler use different rules than yours. And compiler rules may evolve with optimizations.
My robust swap methods are:
int a=15, b=7;
int tmp= a; a= b; b=tmp;
or
int a=15, b=7;
a^=b; b^=a; a^= b;