Skip to content

codegen: fix field offsets in packed structs#17375

Merged
andrewrk merged 2 commits intoziglang:masterfrom
xxxbxxx:packed-struct
Oct 3, 2023
Merged

codegen: fix field offsets in packed structs#17375
andrewrk merged 2 commits intoziglang:masterfrom
xxxbxxx:packed-struct

Conversation

@xxxbxxx
Copy link
Copy Markdown
Contributor

@xxxbxxx xxxbxxx commented Oct 2, 2023

  • 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()

resolves #16615 and #16621 (probably, there's no reproducer)
resolves #16748
resolves #14632

it's an other attempt from #16657

@archaistvolts
Copy link
Copy Markdown
Contributor

seems like this might also address #14632?

 * 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()
@xxxbxxx
Copy link
Copy Markdown
Contributor Author

xxxbxxx commented Oct 3, 2023

seems like this might also address #14632?

now it does...

@andrewrk
Copy link
Copy Markdown
Member

andrewrk commented Oct 3, 2023

Thanks for refreshing the PR, I'll have a look at this tomorrow 👍

@andrewrk
Copy link
Copy Markdown
Member

andrewrk commented Oct 3, 2023

This code looks great and thank you for for the additional test coverage.

@andrewrk andrewrk merged commit 5c3393d into ziglang:master Oct 3, 2023
@xxxbxxx xxxbxxx deleted the packed-struct branch October 8, 2023 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

non byte-aligned nested packed structs Packed structs: failure in assigning to struct fields nested packed struct incorrect behavior

3 participants