-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Description
The layout rules for the f64 type on AIX are very special, and we do not always correctly implement them. #149880 improved the situation, but to my knowledge some cases are still wrong. @workingjubilee please correct be if I am wrong.
Our current best understanding of the rather confusingly-written documentation for this is that
f64generally only has an alignment requirement of 4- However, sometimes
f64fields will be 8-aligned (and possibly this also affects fields of struct types where the struct containsf64)
In particular, we currently compute the wrong layout for this type:
#[repr(C)]
struct Struct {
a1: f64,
a2: u8,
}The size should be 16, but it is 12.
Another one (with the comments indicating what the layout should be):
// Size: 24
#[repr(C)]
struct Floats {
a: f64, // at offset 0
b: u8, // at offset 8
c: f64, // at offset 12
}Currently we compute the same offsets but we give the type a size of 20.
This can't be fully fixed on the Rust side without something like rust-lang/rfcs#3845 to resolve the conflict between the platform C layout and using the standard layout algorithm that repr(C) uses everywhere else.