Quote:
Originally Posted by SaswatPadhi View Post
Or in a single line :
Code: C++
a^=b^=a^=b;
This code has undefined behavior, since it modifies the lvalue a twice without an intervening sequence point.

See http://en.wikipedia.org/wiki/XOR_swap_algorithm

The "Reasons for avoidance in practice" part is also worth a read.
abhisek dash like this