Skip to content

ineffective-bitwise-zero

Default severity: warning

For integers, x & 0 is always zero while x | 0 and x ^ 0 are always x. A zero-valued flag declared directly with iota often indicates that 1 << iota was intended.

Shift-by-zero expressions are accepted because they commonly appear in regular bit-field layouts alongside shifts by 8, 16, and so on.

unchanged := value ^ 0
masked := value & mask