[Bug c++/17507] Problems with shift and increment operator precedence
work at paul dot dubuc dot org
gcc-bugzilla@gcc.gnu.org
Wed Sep 15 20:17:00 GMT 2004
------- 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
More information about the Gcc-bugs
mailing list