This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/26923] byte swap incorrect
- From: "pluto at agmk dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Mar 2006 18:51:04 -0000
- Subject: [Bug c/26923] byte swap incorrect
- References: <bug-26923-12438@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from pluto at agmk dot net 2006-03-29 18:51 -------
It's not a gcc bug. The code relies on the results of intermediate
subexpressions. According to Stroustrup, The C++ Programming Language, section
6.2.2, "The order of evaluation of subexpressions within
an expression is undefined."
You should use sequence points e.g.:
a ^= b, b ^= a, a ^= b;
This is a dup of PR11751
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26923