Let\'s consider the structs :
struct S1 {
int a;
char b;
};
struct S2 {
struct S1 s; /* struct needed to make this compile as C without ty
Let's consider some code:
struct S1 {
int a;
char b;
};
struct S2 {
S1 s;
char c;
};
Let's consider what would happen if sizeof(S1) == 8 and sizeof(S2) == 8.
struct S2 s2;
struct S1 *s1 = &(s2.s);
memset(s1, 0, sizeof(*s1));
You've now overwritten S2::c.
For array alignment reasons, S2 also cannot have a size of 9, 10, or 11. So the next valid size is 12.