When shift count < width of type, it works as expected:
int a = 1 << (8 * sizeof(int) - 1);
printf("%x\n", a); // 80000000
When shift count >= width of type, the result is different every time and there seems no law:
int b = 1 << 8 * sizeof(int); // int b = 1 << (8 * sizeof(int) + 1);
printf("%x\n", b); // such as 59fa2ba8, 5b0f6ba8, 52f46ba8 etc
Well, there is a warning saying warning: shift count >= width of type [-Wshift-count-overflow]. If this can explain the random outcome, then let me put the shift count into a variable:
int k = 8 * sizeof(int);
int c = 1 << k;
int d = 1 << (k + 1);
printf("%x\n", c); // 1
printf("%x\n", d); // 2
The result is totally different from before, this is Circular shift! How to explain this?