---
title: "ineffective-bitwise-zero"
description: "Detect bitwise operations whose zero operand fixes the result."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

## Bad

```go
unchanged := value ^ 0
```

## Good

```go
masked := value & mask
```

Source: https://strider.gempir.com/analyzers/ineffective-bitwise-zero/index.mdx
