---
title: "range-value-address"
description: "Avoid taking addresses of range values."
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.

# range-value-address

**Default severity:** `warning`

Taking the address of a range value points to the iteration copy, not the
corresponding slice or array element. Go 1.22 made variables declared with `:=`
iteration-local, so this is no longer the classic shared-pointer bug, but the
pointer still does not refer back to the source collection. Use an index when
that source identity is intended.

## Bad

```go
for _, value := range values {
	pointers = append(pointers, &value)
}
```

## Good

```go
for index := range values {
	pointers = append(pointers, &values[index])
}
```

Source: https://strider.gempir.com/lints/range-value-address/index.mdx
