# wasm: fix bitcasting to \-and from arrays · gitcafe/zig

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

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

Visibility: public

Requested revision: 2c2bc9c8df3d8205caf4e49f0fcf7496b3d71444

Requested commit: 2c2bc9c8df3d8205caf4e49f0fcf7496b3d71444

Commit: 2c2bc9c8df3d8205caf4e49f0fcf7496b3d71444

Tree: 618084087433ce062167ccd20e9603c963022c91

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: fix bitcasting to -and from arrays

Arrays are currently always passed by reference, this means that we
always keep the value in linear memory and never load it to Wasm's
stack. Scalar values however do get lowered to Wasm's stack.
This means when bitcasting from an array to a scalar value, we must
load the memory of the array as such scalar type. To bitcast
a scalar type to an array, we allocate a new temporary in the
linear data segment, and then store the scalar value there.

```

## Parents

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

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