3 ms·
Brain was not fully loaded yet, thank you. I don't think the struct in struct is relevant in your example by the way. i32 requires 4-bytes alignment. An array
by bombela 1y ago
Brain was not fully loaded yet, thank you.
I don't think the struct in struct is relevant in your example by the way. i32 requires 4-bytes alignment. An array of a struct{3×i32} will be aligned to 12 bytes. Which maintains the 4 bytes alignment of the fields.
If this structure is embedded into another one, it will be padded accordingly to the alignment requirement of the outer field.
{ { 3×i32 } i32 } will be 16 bytes.
{ { 3×i32 } i64 } will be 12, padding 4, 8. Totalling 24.
I am assuming x86_64.