Should we add designated initializer syntax, like C-1999 has? Is there any fundamental breakage/hatred to the idea even if it's officially proposed, like C-1999's variable-length arrays?
Glancing at the feature from a copy of the C-1999 Standard, I'm wondering about a case of how it works with unions. You can specify a non-first member to initialize a union. There is also a rule that if a sub-object is covered more than once then the lexically-last one takes precedence. What about:
MyType whatever = { .variantA = 6, .variantB = 'c' };
where the two members are union siblings. Here, I think the second one takes precedence, so the owning union is initialized via its "variantB" member, and it's set to 'c'.
MyType whatever = { .something.variantA.x = t, .something.variantB.y = 1L };
I expect the same thing to happen. The "something" union member is set to use "variantB" as its current member and anything from "variantA" is ignored. The "y" sub-member is initialized to 1, and any other sub-members are value-initialized (assuming "variantB" is non-union).
An alternate opinion: when a union's active member is changed via a sub-member's initialization, the result should be ill-formed?
MyType whatever = { .s.AA.x = 1, .s.BB[4] = L'x', .s.AA.y = hello };
As before, "AA" and "BB" are union member siblings. At the end of the initialization, the "AA" member of the "s" union is initialized. The "y" sub-member is set to an enumeration, but does the "x" sub-member join the other sub-members in being value-initialized, or is the first initialization clause reinstated (although it was voided by the second)?
Hopefully, someone in C's version of the working group committees has already asked this, since it doesn't seem to be covered in C99. (Maybe C11 already has a resolution.)
Daryle W.