Skip to content

address-nil-comparison

Detect comparisons between a freshly taken address and nil.

Updated View as Markdown

Default severity: warning

Taking the address of an addressable value produces a non-nil pointer whenever evaluation completes, so comparing that address with nil has a fixed result.

The &*pointer form is excluded because it simplifies to pointer, which may legitimately be nil.

Bad

if &value == nil { handle() }

Good

if pointer == nil { handle() }
Navigation

Type to search…

↑↓ navigate↵ selectEsc close