Re: seemingly inconsistent behaviour of ^= with int *

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/08/2011 03:32 PM, Paul LaFollette wrote:
> Kind people,
> I am befuddled, and looking for understanding:
> 
> int a, b;
> a = 7;
> b = 12;
> 
> a ^= b;
> b ^= a;
> a ^= b;
> 
> should swap the contents of a and b (and it does).
> Since ^= associates to the right
> 
> a ^= b ^= a ^= b;
> 
> should do the same thing (and it does).

No, because you're modifying an object more than once between sequence
points.

More at http://c-faq.com/expr/seqpoints.html

Andrew.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux