Segfault with iterator over `var array` on C++
### Description

```nim
iterator foo[T](x: var T): var T =
  yield x

var x: array[3, char]
for a in foo(x):
  let b = a
```

Happens regardless of refc/orc.

Encountered in https://github.com/status-im/nim-json-serialization/pull/99

### Nim Version

all versions including 2.2

### Current Output

```text
a.nim(9)                 a
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
```


### Expected Output

```text
works
```


### Known Workarounds

_No response_

### Additional Information

_No response_