# stage2: pad out \(non-packed\) struct fields when lowering to bytes · gitcafe/zig

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

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

Visibility: public

Requested revision: 15ff891f044102ba6515cb07f40805452420ea24

Requested commit: 15ff891f044102ba6515cb07f40805452420ea24

Commit: 15ff891f044102ba6515cb07f40805452420ea24

Tree: 05e00c580057290dfcfccda0a8483668322aa11f

Author: Jakub Konka

Committer: Jakub Konka

## Message

```
stage2: pad out (non-packed) struct fields when lowering to bytes

* pad out (non-packed) struct fields when lowering to bytes to be
  saved in the binary - prior to this change, fields would be
  saved at non-aligned addresses leading to wrong accesses
* add a matching test case to `behavior/struct.zig` tests
* fix offset to field calculation in `struct_field_ptr` on `x86_64`

```

## Parents

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

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