rust-lang / rust-lang/reference
u64 has an alignment of 8 bytes on i686-pc-windows-msvc instead of 4 as implied in the reference
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- PR merge metrics
- PR metrics pending
Description
The rust reference states:
Most primitives are generally aligned to their size, although this is platform-specific behavior. In particular, on x86 u64 and f64 are only aligned to 32 bits.
This is true for i686-unknown-linux-gnu:
> cat foo.rs
fn main() {
println!("{}", std::mem::align_of::<u64>());
}
> rustc --target i686-unknown-linux-gnu foo.rs && ./foo
4
However, currently on i686-pc-windows-msvc the alignment of u64 is 8 bytes:
> rustc --target i686-pc-windows-msvc foo.rs
> foo.exe
8
The C++ compiler on that platform (at least the one UE uses) aligns u64 inside classes and structs to 4 bytes. I had expected repr(C) in rust do to the same (especially having read the part above from the reference) and was surprised it didn't. As I assume that some code somewhere relies on u64 being aligned to 8 bytes on that target, should the documentation in the reference be changed to reflect this difference?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rust Reference type-layout page cited in the issue and verify the reported u64 alignment on i686-pc-windows-msvc against i686-unknown-linux-gnu and the platform's C++ behavior. Done means the reference accurately explains the target-specific alignment, or the issue is redirected if the implementation behavior needs correction first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100