Re:Who Says C is Simple? (2010)
by klodolph on Sunday March 08, 2015 @06:56PM
(#9167747)
The behavior is only well defined if the shift amount is strictly less than the width of the operand. If `size_t` is 32 bits, then shifting right by 32 bits is undefined.
I know of three different ways in which platforms implement shifts by greater than the word size.
Re:Who Says C is Simple? (2010)
by EpicEng on Sunday March 08, 2015 @08:00PM
(#9167964)
Yep, you're right. I knew left shift for signed/unsigned as it is more complicated and I've had to look it up more often, but I forgot that right shift can be UB for unsigned integral types as well.
I know of three different ways in which platforms implement shifts by greater than the word size.