For scalar values, the assignment operator seems to copy the right-hand side value to the left. How does that work for composite data types? Eg, if I have a nested struct
struct inner {
int b;
};
struct outer {
struct inner a;
};
int main() {
struct outer s1 = { .a = {.b=1}};
struct outer s2 = s1;
}
- does the assignment recursively deep copy the values?
- does the same happen when passing the struct to a function?
By experimenting it seems like it does, but can anyone point to the specification of the behavior?