For some reason I had this idea that C and C++ worked like this:
int foo[10] = {57};
for (int i=0; i<10; ++i)
assert (foo[i] == 57);
Turns out the remaining ints are initialized to 0, not 57. Where did I get this idea? Was this true at one point? Was it ever true for structure initializer lists? When did arrays and structures neatly and correctly start initializing themselves to 0 values when assigned to = {} and = {0}? I always thought they’d initialize to garbage unless explicitly told otherwise.
It’s been this way forever, as long as initializers existed. C89 says: