# stage1: Fix bitcast of immediate to ptr type \(\#5131\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/e6428f94013132b6a6284b053afb36d35af63c59)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: e6428f94013132b6a6284b053afb36d35af63c59

Requested commit: e6428f94013132b6a6284b053afb36d35af63c59

Commit: e6428f94013132b6a6284b053afb36d35af63c59

Tree: 86275c7d4d6c0729a0905e4e9e2abca1371f1fed

Author: LemonBoy

Committer: GitHub

## Message

```
stage1: Fix bitcast of immediate to ptr type (#5131)

Consider a (legal according to the `@bitCast` rules) conversion from u16
to [2]u8: since the former is a scalar and the latter is a pointer
(arrays are represented at pointers in the codegen phase) we have to
allocate a temporary slot on the stack and then bitcast the resulting
pointer to the desired destination type.

Beware that this means the lifetime of the resulting value is the same
of the function it's contained in and for all intents and purposes
should be regarded as a local (eg. it should not escape).

Closes #4395
Closes #5121

```

## Parents

- [58d5c37409a7fc7fea2d6c536bf53c0193c5266a](https://git.cafe/gitcafe/zig/commit/58d5c37409a7fc7fea2d6c536bf53c0193c5266a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/e6428f94013132b6a6284b053afb36d35af63c59?format=markdown)
