-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Incorrect field offset when using #[repr(C, packed(8))] #128373
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
Comments
It seems that gcc's gcc's
In other words, it only affects the starting address of the struct, not the layout of the members rust's
In other words, rust's specifier adjusts the layout of the members to satisfy the alignment specified by |
This seems like a duplicate of #59154. The rust equivalent would be |
Closing as duplicate. If these are auto-generated tests from bindgen, then please report the test bug(?) to rust-bindgen, as bindgen should either
|
Probably the last one. |
I'm using bindgen to create bindings for a library. It appears that rustc is not packing the structs in the same way as clang/gcc.
bindgen generates the following:
I expected to see this happen:
The bindgen tests pass. The
e
field is at offset 20.Instead, this happened:
The bindgen tests fail. The
e
field is at offset 24.Reproduced with a smaller example:
bindgen generates the following:
I expected to see this happen:
The bindgen tests pass. The
g
field is at offset 4.Instead, this happened:
The bindgen tests fail. The
g
field is at offset 8.With gcc and clang:
clang:
gcc:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: