Take this structure for example:
struct Packing
{
int x; // 4-byte align
int y; // 4-byte align
short int z; // 2-byte align
char m; // 1-byte align;
char _pad[1]; // explicit padding
};
The sizeof this structure is 12-bytes.
So should store this struct in addresses multiples of the struct size (12-bytes) or in multiples of sizeof(int) (the largest alignment requirement among the members of the struct)?
Since multiples of 12 are also multiples of 4 (sizeof(int)) I guess the struct will be correctly aligned in addresses multiples of 12, but I might waste space that wouldnt be wasted if it was 4-byte aligned.
EDIT: At address 0x00000012 the structure would be aligned and the its first member would also be aligned because 12 is a multiple of 4.
What if stored it at address 0x00000004? In this case the first element of the struct would be aligned but what about the structure itself?
The optimal alignment for a struct is equal to the largest alignment for any of the struct’s members. In this case that is 4.
Update
The above assumes that the primary operation you perform on the struct is accessing its members. See the comments to Necrolis’s answer for more discussion. In short I suspect that the real answer to your question depends strongly on the hardware involved and the algorithms you are using.