Possible Duplicate:
Size of struct with a single element
Given any type A and the following struct:
struct S
{
A a;
};
Are there any cases where sizeof(S) is greater than sizeof(A)?
For example, can sizeof(std::array<T, n>) be greater than sizeof(T[n])?
While the struct can be padded, on all systems I know, the compiler will pad so that the alignment of the structure is the same as the largest alignment of its members. It does this so that an array of the structure will always be correctly aligned.
So:
Edit: Note, that compilers can also add internal padding, to keep the alignment of the data correct.
The C/C++ standard doesn’t specify any of these detail. What you want is the C ABI (application binary interface) for the system you’re running on, which should specify default layout for structs (compilers can choose to override this if they see fit, see also #pragma pack). For an example, look at the X86_64 ABI page 13, which states: