I recently learned that copying partially initialized structures through trivial construction or assignment is undefined in C++. Does the same hold true in C or does the standard guarantee that initialization and assignment behave like memcpy
?
typedef struct { int i; int j; } A;
void foo() {
A x;
x.i = 0;
// Leave x.j indeterminate. Is the following well defined?
A y = x;
y.j = y.i + 1;
}