From this comment in GCC bug #53119:
In C,
{0}is the universal zero initializer equivalent to C++'s{}(the latter being invalid in C). It is necessary to use whenever you want a zero-initialized object of a complete but conceptually-opaque or implementation-defined type. The classic example in the C standard library ismbstate_t:mbstate_t state = { 0 }; /* correctly zero-initialized */versus the common but nonportable:
mbstate_t state; memset(&state, 0, sizeof state);
It strikes me as odd that the latter version could be unportable (even for implementation-defined types, the compiler has to know the size). What is the issue here and when is a memset(x, 0, sizeof x) unportable?