Why is not 12 in the first case? Tested on: latest versions of gcc and clang, 64bit Linux
struct desc
{
int** parts;
int nr;
};
As the previous answer indicated, the compiler is allowed to add padding. This is usually done because sometimes the hardware requires that certain data types must occur on certain memory boundaries. It looks like your system wants to put pointers on an 8-byte boundary.
The padding is at the end of the structure and is necessary so that each element in an array of struct desc will still be on an 8-byte boundary.