Hacker News new | ask | show | jobs
by thrwyexecbrain 1560 days ago
The sizeof(variant) example is wrong. An extra byte is needed to store the discriminator value, which in practice results in 8 extra bytes for these particular types because of alignment. https://godbolt.org/z/vno3v9rPK

The tuple drawing is also somewhat misleading, because the first box (int) should be the same size as the second one (double), due to alignment.

1 comments

You are right. That was probably dumbed down too much. I'll fix it.