Mettle

M0115Shift count at or past the operand width

Reported by the compiler as an error or warning.

mettle explain M0115

Shifting a 32-bit value by 32, or a 64-bit value by 64, does not produce zero. The hardware masks the count (x86 uses the low 5 or 6 bits), so x << 32 on an int32 is x << 0, which is x.

Fix: shift by less than the width, or widen the operand first:

var wide: int64 = (int64)x;
var shifted: int64 = wide << 32;

Related