On Fri, 16 Jun 2023, Qing Zhao via Gcc-patches wrote:
> > So for
> >
> > struct foo { int c; int buf[(struct { int d; }){ .d = .c }]; };
> >
> > one knows during parsing that the .d is a designator
> > and that .c is not.
>
> Therefore, the above should be invalid based on this rule since .c is
> not a member in the current structure.
What do you mean by "current structure"? I think two different concepts
are being conflated: the structure *being initialized* (what the C
standard calls the "current object" for a brace-enclosed initializer
list), and the structure *being defined*. The former is what's relevant
for designators. The latter is what's relevant for the suggested new
syntax. And .c *is* a member of the structure being defined in this
example.
Those two structure types are always different, except for corner cases
with C2x tag compatibility (where an object of structure type might be
initialized in the middle of a redefinition of that type).
--
Joseph S. Myers
[email protected]