In the old days structure like that:
typedef struct A {
int m_i;
int m_j;
} A;
Allocated on the heap or declared locally in a function without being memset
would have its members uninitialized.
However, to my utter surprise this little program shows it is always set to 0.
#include <stdio.h>
typedef struct A {
int m_i;
int m_j;
} A;
void f(const A& a) {
printf("i=%i, j=%i\n", a.m_i, a.m_j);
}
void y() {
f({10});
}
int main() {
y();
return 0;
}
Built using g++ -std=c++11 a.cpp
I would just in case defined a constructor to make sure they are zero, but my various tests show (using code found on the internet) that I don't have to.
Is this a shear coincidence or extended initializer list is a guarantor of having memory being memset?