This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/39121] strange behavior in chained operations


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39121

--- Comment #7 from joe.carnuccio at qlogic dot com ---
Ok, the sequence points are at each of the assignment operators.

The crux of this is that doing the xor chain with dereferenced pointers fails
(incorrect execution), whereas doing it with variables works...

i.e. *a and *b are being treated differently than a and b;


a ^= b ^= a ^= b is supposed to do the following:

a = a ^ (b = b ^ (a = a ^ b))

from right-to-left each assignment is done in sequence (and has been verified
to work correctly);


*a ^= *b ^= *a ^= *b should work the same way, but it does not (unless you
compile with -Os).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]