Why is not 12 in the first case? Tested on: latest versions of gcc and clang, 64bit Linux
struct desc
{
int** parts;
int nr;
};
The compiler is allowed to add padding between struct members to make processing more efficient. This padding varies by platform, compiler version etc. It's one of the things that make sending structs over the network impossible.
You can use offsetof to find out where exactly your compiler is adding paddings.