What does the C standard say about bitshifting more bits than the width of type?

From my WG12/N1124 draft (not the standard, but Good Enough For Me), there’s the following block in 6.5.7 Bitwise shift operators:

If the value of the right operand is negative or is
greater than or equal to the width of the promoted left operand, the behavior is undefined.

So, undefined. Be careful.

Leave a Comment