<=> and obfuscation
Bill Stewart HO 4K-435 x0705
stewart at houxf.UUCP
Thu Feb 14 03:06:39 AEST 1985
People have been arguing about the statement that
b ^= a ^= b ^= a;
gives 0 when a and b are the same. However, you've misunderstood the original
statement - the problem is not when a and b have the same VALUE, but when they
have the same ADDRESS. Yes, it works fine when a and b are different variables
with the same value. However, in a subroutine you might get two variables with
the same address. Then the statement is equivalent to
a ^= a ^= a ^= a
Well, a^=a becomes zero, gets ^ed with a, which is now 0m and gets ^ed with 0
again, still giving 0.
--
Bill Stewart ho95c!wcs AT&T Bell Labs, Holmdel NJ
HO 4K-435 x0705 (201-949-0705)
{allegra, ucbvax!ihnp4, decvax!harpo}!houxf!stewart
------
Sorry if the articles I'm replying to re ancient; we lost news for a month.
More information about the Comp.lang.c
mailing list