4 ms·
Right! So you agree now that structures are not "usually 64-bit aligned on x86"?
by BeeOnRope 7y ago
Right!
So you agree now that structures are not "usually 64-bit aligned on x86"?
- dragontamer 7y agoWell, 32-bit aligned in this case. But its not 8-bit aligned :-)
- BeeOnRope 7y agoOf course it is not 8-bit aligned! I never said everything was 8-bit aligned, just that your alignment claim was bizarre. ints will always be (at least) 32-bit aligned. The rules are simple [1]: 1-byte primitives (e.g., chars) are 1-byte aligned 2-byte primitives (e.g., shorts) are 2-byte aligned 4-byte primitives (e.g., ints) are 4-byte aligned 8-byte primitives are 8-byte aligned Etc. The rules for structures are also simple: they will have the alignment of their highest alignment member. That makes sense: the language rules (and ABI) are designed to make sure that primitives have (at least) the above alignment, regardless of where they are: putting them into a structure (or array, etc) can't violate that. This is basically common across any modern platform too - not x86 specific, although some details may vary (e.g., size of primitives). There are weird cases too, like on some 32-bit platforms even (some) 64-bit values are only 32-bit aligned, and the whole 80-bit long double thing, etc: but the basic rules hold. --- [1] Here I give some examples of data types that _commonly_ have the given size, but except for char this is not always true (e.g., some platforms have 8 byte ints, and some have 4 byte longs).