In your calculations, it is assumed that double should be aligned by 8 bytes. This does not apply to all architectures.
On 32-bit x86 Linux with GCC, double will default to 4 byte alignment. You can change this with the -malign-double flag to make it 8-byte.
So, a layout assuming default values ββon 32-bit x86 Linux:
char // 1 byte // 3 byte padding double // 8 bytes int // 4 bytes
So, a total of 16 bytes, with 3 bytes of padding in the middle.
In a Wikipedia article, data structure alignment has size / alignment numbers for various types on 32-bit x86 and 64-bit x86_64 in several compilers / environments.
source share