This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/39121] strange behavior in chained operations
- From: "joe.carnuccio at qlogic dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 25 Jun 2015 19:40:05 +0000
- Subject: [Bug c/39121] strange behavior in chained operations
- Auto-submitted: auto-generated
- References: <bug-39121-4 at http dot gcc dot gnu dot org/bugzilla/>
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).