-
Notifications
You must be signed in to change notification settings - Fork 13k
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(4))] struct has 8 byte alignment #48159
Comments
cc #33626 If we follow the text of the original RFC 1358, this is intended: // Lowering has no effect
#[repr(align = "1")]
struct Align1(i32); so the problem is missing diagnostic. Not sure if portability lint is needed due to the pointer-sized things. |
Might be that what we need here is just |
It would be nice to have a lint to warn you you when |
How would that lint work portably? What say you wanted 8 byte alignment on all targets with
the lint would fire on 64-bit targets. |
In that case you can just |
Or use |
Btw, why doesn't |
Probably because you can't do that in C. At least for |
@retep998 Just because it's not possible in C doesn't mean it can't be possible in LLVM / Rust. Even if it's only possible on a struct, rustc could auto-generate a wrapper struct for the codegen and auto-wrap the member in it, if it has that attribute. |
@Boscop I'm not saying we shouldn't have that feature, I'm just explaining why we don't have that yet. Feel free to open an issue or PR about that extension of |
Prior art: In C++, an |
See it live:
No warning, no error, nu nothing.
This is rust-lang/libc#914
The text was updated successfully, but these errors were encountered: