Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!ctrsol!ginosko!uunet!amgraf!cpsolv!rhg From: rhg@cpsolv.UUCP (Richard H. Gumpertz) Newsgroups: comp.lang.c Subject: Re: Obfuscated SWAP: not portable! Message-ID: <173@cpsolv.UUCP> Date: 8 Sep 89 15:47:31 GMT References: <784@skye.ed.ac.uk> <1267@levels.sait.edu.au> <149@cpsolv.UUCP> <1400@levels.sait.edu.au> Reply-To: rhg@cpsolv.uucp (Richard H. Gumpertz) Organization: Computer Problem Solving, Leawood, Kansas Lines: 11 "x ^= y ^= x ^= y" differs from "x = y = z = 0" in that the former makes TWO assignments to x. Side effects (i.e., assignments to variables) need only be completed at "sequence points"; between sequence points, any order of evaluation (including assignment operators) is allowed! The following are all legal interpretations of the sequence in question, yet may yield different results: (t = x ^= y, x ^= y ^= t) (t = x, y ^= x ^= y, x = t ^ y) (t = x ^ y, x ^= y ^= t, x = t) I am sure there are other interpretations as well.