Open
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?