Stephen Heumann <
stephen...@gmail.com> writes:
> I'm trying to figure out how initialization of anonymous
> structures and unions is supposed to work, particularly when
> using brace-enclosed initializer lists without designators.
> [..elaboration..]
>
> In general, GCC and Clang seem to be acting like an anonymous
> structure or union participates in initialization as a structure
> or union, even though it is unnamed. This would be a reasonable
> thing to do in the abstract, but I don't see how it agrees with
> the wording in the standard. Am I missing something, or do GCC
> and Clang get this wrong?
Short answer: I think what clang and gcc are doing is right.
Slightly longer answer: I can see how the wording used in the C
standard could be read in the way that clang and gcc behave. I
agree that other readings are plausible, and that at the very
least clarification is needed, and probably re-writing. What
clang and gcc do doesn't surprise me; on the contrary it's what
I would expect if your comments hadn't drawn my attention to the
question. If your goal is to understand the rules I think there
isn't any more to say. If your goal is to understand how the
rules follow from the wording, I think the question needs to be
put to the WG14 committee, perhaps in the form of a DR or change
request or whatever it is those are called these days.
Hope this helps, and good luck.