Sequence Points, Swapping Vars (Was Re: Is...wrong with the compiler?)

Henry Spencer henry at zoo.toronto.edu
Sun Sep 30 09:52:18 AEST 1990


In article <BURLEY.90Sep29045736 at world.std.com> burley at world.std.com (James C Burley) writes:
>... the other thread(s) I've seen posting solutions
>such as "a^=b^=a^=b" (or some such thing) for the problem of swapping integer
>variables.  If ^= also is not a sequence point, isn't it valid for a
>conforming C compiler to write into a the result of XORing the original values
>of a and b, instead of the final value...

Yes indeed.

Note that most of the really knowledgeable readers in this group have
seen the variable-swapping nonsense too many times to pay much attention
to the latest round of cutesy solutions to a non-problem.
-- 
Imagine life with OS/360 the standard  | Henry Spencer at U of Toronto Zoology
operating system.  Now think about X.  |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list