Skip to content

oversized-fixed-width-shift

Detect shifts that always clear fixed-width integers.

Updated View as Markdown

Default severity: warning

Shifting a fixed-width integer by its full width or more always clears every value bit. This is usually an incorrect shift count. Machine-sized int, uint, and uintptr are excluded because width-dependent bit manipulation can be intentional.

Bad

value := uint8(1) << 8

Good

value := uint8(1) << 7
Navigation

Type to search…

↑↓ navigate↵ selectEsc close