/* Assume sizeof(int) == sizeof(unsigned int) == 4 */
/* and that UINT_MAX = 2^32 -1 */
int a = 1;
int b = -1;
a << b; /* Undefined because b is signed and negative (rule 3) */
int c = -1;
int d = 1;
c << d; /* Undefined because c is signed and negative (rule 4) */
int e = 1;
int f = 31;
e << f /* Undefined because 2147483648 can't be represented in a 32 bit signed int */
unsigned int g = 1;
unsigned int h = 31;
g << h /* Well defined because 2147483648 can be represented in a 32 bit unsigned int */
int i = 1;
int j = -1;
i >> j; /* Not defined. j is negative, rule 3. */
int k = -1;
int l = 1;
k >> l; /* Implementation defined. See rule 5. */
/* Left shift cases where both operands are promoted to unsigned
integers are well defined and equal to (E1 * 2^E2) mod UINT_MAX */
/* Right shift cases where both operands are promoted to unsigned
integers are well defined if E2 <= 31 */
/* Right shift cases where both operands are promoted to unsigned
integers are undefined if E2 > 31 */
/* Conclusions contingent on 32 bit assumption stated above */