The answer for A is “something else.”
The size of a structure must be at least the offset of its last member plus the size of that member plus enough padding bytes to make the structure’s size a multiple of its alignment requirement (which equals the largest alignment requirement of any of its members). A C implementation may add additional padding bytes in multiples of the alignment requirement, although I know of none that do.
The answer for B is the alignment requirement of the structure (its _Alignof
value) equals strictest alignment requirement of its members (the largest _Alignof
value of them).
In particular, note that C 2018 6.2.7 4 says “… Every valid alignment value shall be a nonnegative integral power of two.” Thus, if any alignment satisfies the strictest member alignment requirement, it satisfies each member alignment requirement, so it is sufficient.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…