On Thu, 13 Nov 2025, Qing Zhao wrote:

> > Maybe this suggests that, as in other cases, an anonymous structure or 
> > union involving counted_by should actually be required to be valid without 
> > reference to the containing struct or union after all -
> 
> So, you mean, we should not support the following case: (requested by 
> PR122495 and PR122496):
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122495
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122496
> 
> struct fam_in_union {
>   int count;
>   union {
>     char a;
>     char fam[] __counted_by(count);
>   };
> };
> 
> Since the “counted_by” field, “count”,  that is referenced inside the 
> anonymous union is declared
> in the outer containing structure.
> ??

Indeed.  That would be consistent with how anonymous structs and unions 
work in other cases, but I don't know if you have use cases that want this 
example to work.

-- 
Joseph S. Myers
[email protected]

Reply via email to