Alignment of aggregates

The data contained in Table 1 (in Using alignment modes) apply to scalar variables, and variables that are members of aggregates such as structures, unions, and classes. The following rules apply to aggregate variables, namely structures, unions or classes, as a whole (in the absence of any modifiers):

The following table shows some examples of the size of an aggregate according to alignment mode.
Table 1. Alignment and aggregate size
Example Size of aggregate
-qalign=power -qalign=natural -qalign=packed

struct Struct1 {  
double a1;    
char a2;
};

16 bytes (The member with the largest alignment requirement is a1; therefore, a2 is padded with 7 bytes.) 16 bytes (The member with the largest alignment requirement is a1; therefore, a2 is padded with 7 bytes.) 9 bytes (Each member is packed to its natural alignment; no padding is added.)

struct Struct2 {
char buf[15];
};

15 bytes 15 bytes 15 bytes

struct Struct3 {  
char c1;        
double c2;
};

12 bytes (The member with the largest alignment requirement is c2; however, because it is a double and is not the first member, the 4-byte alignment rule applies. c1 is padded with 3 bytes.) 16 bytes (The member with the largest alignment requirement is c2; therefore, c1 is padded with 7 bytes.) 9 bytes (Each member is packed to its natural alignment; no padding is added.)
Notes:

For rules on the alignment of aggregates containing bit fields, see Alignment of bit fields.