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++/17507] Problems with shift and increment operator precedence


------- 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


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