Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[repr(align(n), C)] and #[repr(packed, C)] are not represented correctly #430

Closed
cyphar opened this issue Dec 12, 2019 · 0 comments · Fixed by #431
Closed

#[repr(align(n), C)] and #[repr(packed, C)] are not represented correctly #430

cyphar opened this issue Dec 12, 2019 · 0 comments · Fixed by #431

Comments

@cyphar
Copy link
Contributor

cyphar commented Dec 12, 2019

#[repr(align(n), C)] markers on a struct should be translated to __attribute__((align(n)), similarly for #[repr(packed, C)] for __attribute__((packed)). Right now they are generated as being opaque structs. This is necessary to implement a Rust-based __attribute__((packed)) (by setting #[repr(align(1))]).

Additionally, #[repr(align(n))] and #[repr(C)] separately applied on the same struct (which AFAIK is equivalent to #[repr(align(n), C)]) will result in the structure being generated as a non-opaque struct but with the wrong alignment (resulting in C code passing incorrect structs to Rust code -- which won't end well).

@cyphar cyphar changed the title #[repr(align(n))] is not represented correctly #[repr(align(n), C)] and #[repr(packed, C)] are not represented correctly Dec 13, 2019
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 a pull request may close this issue.

1 participant