Move your own danger. By standard, you want to make undefined behavior .
C99 Β§6.5.7
3 . Integer promotions are executed on each of the operands. The result type is the advanced left operand. If the value of the correct operand is negative or greater than or equal to the width of the advanced left operand, the behavior is undefined.
In other words, if you try to shift a 32-bit value to something greater than 31 bits or a negative number, you will get undefined.
source share