Skip to content

ty: More struct layout fixes for overaligned integers / aliases. - #3458

Merged
emilio merged 1 commit into
mainfrom
more-overaligned-stuff
Sep 7, 2026
Merged

ty: More struct layout fixes for overaligned integers / aliases.#3458
emilio merged 1 commit into
mainfrom
more-overaligned-stuff

Conversation

@emilio

@emilio emilio commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This fixes most of the test-cases discussed in #3453.

The remaining one is related to bitfields and needs a bit more thought (I think we currently don't pad bitfields based on the clang-reported offset and maybe should).

This fixes most of the test-cases discussed in #3453.

The remaining one is related to bitfields and needs a bit more thought
(I think we currently don't pad bitfields based on the clang-reported
offset and maybe should).
@emilio
emilio force-pushed the more-overaligned-stuff branch from 5344e5d to cc051ab Compare September 7, 2026 11:58
@emilio

emilio commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

cc @ojeda

@emilio
emilio added this pull request to the merge queue Sep 7, 2026
Merged via the queue into main with commit dc61531 Sep 7, 2026
51 checks passed
@ojeda

ojeda commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This seems to fix most of them, and it is reassuring to have them as tests, thanks!

With this PR, the case of passing --opaque-type AlignedInner aligns that one to 8 instead of 0.72.1's (and Clang's) 16.

@emilio

emilio commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Can you elaborate? Opaque types seem to work fine here as well? It gets aligned to 8 but padded, so effectively it gets aligned to 16, right?

@ojeda

ojeda commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Yeah, I meant that the alignment of the opaque type itself will be different (even if bindgen generates padding when using that type elsewhere).

So if someone uses that type on both C and Rust, it could subtly break (e.g. Rust generates a pointer to a value not actually aligned to 16 that we pass to C).

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.

2 participants