This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17507] Problems with shift and increment operator precedence
- From: "work at paul dot dubuc dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Sep 2004 20:17:01 -0000
- Subject: [Bug c++/17507] Problems with shift and increment operator precedence
- References: <20040915184232.17507.work@paul.dubuc.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From work at paul dot dubuc dot org 2004-09-15 20:17 -------
(In reply to comment #2)
> *puc++ << 24 | *puc++ << 16 | *puc++ << 8 | *puc++
>
> That statement is undefined because puc++ can happen in any order.
OK, I guess the Standard allows for this, but there are still 2 points to be made:
1) Why is the value of puc only incremented once instead of 4 times? That still
seems like a bug.
2) This works as I had expected:
--puc;
unsigned int uint = *++puc << 24 | *++puc << 16 | *++puc << 8 | *++puc;
output:
./testg2 abcdefgh
pui=0xffbeea18 *pui=64656667
puc (before)=0xffbeea18
puc (after)=0xffbeea1b uint=64656667
which seems inconsistent since the preincrement can also happen in any order.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17507