由無效的職位數量轉移

對於內建移位運算子,右運算元必須是非負的並且嚴格小於提升的左運算元的位寬。否則,行為未定義。

const int a = 42;
const int b = a << -1; // UB
const int c = a << 0;  // ok
const int d = a << 32; // UB if int is 32 bits or less
const int e = a >> 32; // also UB if int is 32 bits or less
const signed char f = 'x';
const int g = f << 10; // ok even if signed char is 10 bits or less;
                       // int must be at least 16 bits