In code like the following, we typically have an implicit pad of 2 bytes at the end of the structure:
struct foo {
int32_t x ;
int16_t y ;
// <<< 2 bytes for total sizeof(foo) == 8
} ;
I was asked today what an aggregate initializer does with the extra two bytes:
foo o = { 0, 0 } ;
ie: is this going to be equivalent to
foo o ;
memset( &o, 0, sizeof(foo) ) ;
I had no clue, so I recommended not to depend on that (aggregate initialers are troublesome anyways so that's good general advise IMO).
Does anybody know if the C language spec says anything about what an aggregate initialization does with implicit padding when the platform ABI requires such padding for the specific structure in question?