Undefined behavior happens. That's standardized by the language standard (See section 6.5.7 Bitwise shift operators
of the C standard from 1999). The observable effects of UB are not standardized, however, and may vary.
As for shl eax, 22h
, the shift count is going to be truncated to 5 bits by the CPU (see the documentation) and this instruction will really behave as shl eax, 2
.