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

Reference to packed field is unaligned [error] #86

Open
pronebird opened this issue Apr 30, 2024 · 0 comments
Open

Reference to packed field is unaligned [error] #86

pronebird opened this issue Apr 30, 2024 · 0 comments

Comments

@pronebird
Copy link
Contributor

Hi,

I found a lot of errors like this when trying to compile tests:

error[E0793]: reference to packed field is unaligned
    --> src/ffi/pfvar.rs:2348:18
     |
2348 |         unsafe { &(*(::std::ptr::null::<pfsync_state_scrub>())).pfss_flags as *const _ as usize },
     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
     = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
     = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)

Probably bindings need to be updated

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