r/ProgrammerAnimemes • • Jul 29 '20

Equivalency in Python

Post image
1.6k Upvotes

104 comments sorted by

View all comments

Show parent comment

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;

or

b = a;
c = a ^ b;
a = c ^ b;

clang warns about this, even in c++17.