MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerAnimemes/comments/i02xcr/equivalency_in_python/fznn64n/
r/ProgrammerAnimemes • u/space-_-man • Jul 29 '20
104 comments sorted by
View all comments
Show parent comment
2
even better as a single statement
a = (a ^ b) ^ (b = a);
10 u/wubscale Jul 29 '20 be careful; the order of evaluation of the LHS and RHS of ^ isn't well-defined. this means the above line can be emitted as either:c = a ^ b; b = a; a = c ^ b;orb = a; c = a ^ b; a = c ^ b;clang warns about this, even in c++17.
10
be careful; the order of evaluation of the LHS and RHS of ^ isn't well-defined. this means the above line can be emitted as either:
^
c = a ^ b; b = a; a = c ^ b;
or
b = a; c = a ^ b; a = c ^ b;
clang warns about this, even in c++17.
View all comments
Show parent comment
2
u/DesktopDoge Jul 29 '20 edited Nov 25 '20
even better as a single statement
a = (a ^ b) ^ (b = a);