Under GCC, the following code always return the left operand of <<
if num1s == 0
:
0xFFFFFFFFu << (32-num1s);
After reading Why doesn't left bit-shift, "<<", for 32-bit integers work as expected when used more than 32 times?, and the standard quoted by David Heffernan, it seems that if the left operand is unsigned, it is a defined operation. It is only when E1 (the left operand) has a signed type and non-negative value that it could result in undefined behavior.
Can any one explain if the standard states explicitly that if the amount shifted is larger than the number of bits the type contains, it is undefined behavior?