# codegen: fix field offsets in packed structs · gitcafe/zig

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

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

Visibility: public

Requested revision: 62d178e91af57c19d0ac000fe6930039a23e53a3

Requested commit: 62d178e91af57c19d0ac000fe6930039a23e53a3

Commit: 62d178e91af57c19d0ac000fe6930039a23e53a3

Tree: f849674dd8aa13839319e05585b8513a0192b7ba

Author: Xavier Bouchoux

Committer: Xavier Bouchoux

## Message

```
codegen: fix field offsets in packed structs

 * add nested packed struct/union behavior tests
 * use ptr_info.packed_offset rather than trying to duplicate the logic from Sema.structFieldPtrByIndex()
 * use the container_ptr_info.packed_offset to account for non-aligned nested structs.
 * dedup type.packedStructFieldBitOffset() and module.structPackedFieldBitOffset()

```

## Parents

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

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