I have this struct definitions:
struct inner
{
int i;
std::string str;
};
struct outer
{
inner member[32];
};
Now I want to create a value-initialized instance of outer
, so I write
outer o = {};
With GCC, this works just fine: all inner.i
are zeroed and all inner.str
are empty. But on VS2013, only the inner.str
are empty; all inner.i
contain garbage i.e. are not properly initialized.
Without the std::string
member, the zero-initialization of inner.i
works with VS2013.
What does the standard say on this? I always assumed {}
initializes everything, either by zeroing or by calling the default constructor. Am I wrong or is this a very bad bug in VS2013?