I already read this question: struct padding in c++ and this one Why isn't sizeof for a struct equal to the sum of sizeof of each member?
and I know this isn't standardized but still I believe it's a legit question.
Why is the size of this struct 16 on a x64 system?
struct foo { char* b; char a;};
The effective size would be 8 + 1 = 9, but I know there's padding involved. Anyway I thought a
would only be padded to reach the size of an int
, i.e. with other 3 bytes giving a total of 12 bytes.
Is there any reason why the specific compiler (gcc) thought it should have 16 bytes as a size?
Wild guess: is it possible that the biggest type (e.g. double or in this case x64 pointer) will dictate the padding to use?