logoalt Hacker News

praptaktoday at 7:30 AM1 replyview on HN

Xor swap trick has perfect profile for underhanded C contests. It generally works until a specific condition triggers its failure. The condition is "the arguments are aliases", so for example XOR_SWAP(a[i], a[j]) when i=j.


Replies

imploded_subtoday at 9:51 AM

TFA mentions this as an issue for the trick, whereas you rightly point out it's an evil feature instead.