Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!amgraf!cpsolv!rhg From: rhg@cpsolv.UUCP (Richard H. Gumpertz) Newsgroups: comp.lang.c Subject: Re: Obfuscated SWAP: not portable! Message-ID: <149@cpsolv.UUCP> Date: 1 Sep 89 08:43:30 GMT References: <784@skye.ed.ac.uk> <1267@levels.sait.edu.au> Reply-To: rhg@cpsolv.uucp (Richard H. Gumpertz) Organization: Computer Problem Solving, Leawood, Kansas Lines: 11 The exchange of x and y that has been under discussion: x ^= y ^= x ^= y is non-portable because it depends on right-to-left evaluation which is NOT specified in the C standard. To be portable, use (x ^= y, x ^= y ^= x) or (y ^= x ^= y, x ^= y) either of which forces the two assignments to x to be done in a well-defined order. Richard H. Gumpertz I am the company, so no disclaimer is needed! :-)