-
Notifications
You must be signed in to change notification settings - Fork 707
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
Improve the UB situation in layout tests. #2064
Conversation
This patch addresses this issue rust-lang/rust-bindgen#2064. While we access field of packed struct the compiler can generate the correct code to create a temporary variable to access the packed struct field. Access withing {} ensures that. Signed-off-by: Muminul Islam <[email protected]>
This patch addresses this issue rust-lang/rust-bindgen#2064. While we access field of packed struct the compiler can generate the correct code to create a temporary variable to access the packed struct field. Access withing {} ensures that. Signed-off-by: Muminul Islam <[email protected]>
This patch addresses this issue rust-lang/rust-bindgen#2064. While we access field of packed struct the compiler can generate the correct code to create a temporary variable to access the packed struct field. Access withing {} ensures that. Signed-off-by: Muminul Islam <[email protected]>
Hi @emilio, is there anything blocking you from merging this? It would be super helpful for all the projects using bindgen :) |
Yeah, some tests are failing, I don't recall the specifics, need to look into that, will re-push. |
- Replaced dereferencing of null ptr with zero bit pattern + transmute + std::ptr::addr_of! to avoid UB. It affects only checks of fields offsets - Overwritten expected with BINDGEN_OVERWRITE_EXPECTED=1 - Overwritten test_multiple_header_calls_in_builder and test_mixed_header_and_header_contents manually because #2054 - Do not check the layout for repr(C) unions - Do not call the destructor of tmp struct to avoid other UB
87097af
to
284dd3c
Compare
Out of curiosity, why zero memory and not a (Using MaybeUninit like that is explicitly defined here: https://doc.rust-lang.org/beta/std/mem/union.MaybeUninit.html#initializing-a-struct-field-by-field) |
☔ The latest upstream changes (presumably 310f7f8) made this pull request unmergeable. Please resolve the merge conflicts. |
This is #2055 with some extra fixes