Am Donnerstag, dem 13.11.2025 um 20:41 +0000 schrieb Qing Zhao:
>
> > On Nov 13, 2025, at 14:17, Martin Uecker <[email protected]> wrote:
> >
> > Am Donnerstag, dem 13.11.2025 um 15:44 +0000 schrieb Qing Zhao:
> >
> > >
>
> >
> > >
> > > >
> > > > You would then check correctness of the attribute only when the parent
> > > > type is complete.
> > >
> > > Okay.
> > > >
> > > > If we want to support counted_by in even more generic cases,
> > >
> > > What kind of more generic cases? Any example?
> >
> > I was thinking about
> >
> > struct bar {
> > char *buf __counted_by(n);
> > };
> >
> > struct foo {
> > int n;
> > struct bar;
> > };
> >
> > which is allowed with -fms-extensions.
> >
> > I don't think we should support this.
>
> Don’t support this even when -fms-extensions is enabled?
Yes, because then you can't emit an error for
struct bar anymore (e.g. as the in the following example),
because we can't know whether it might be used later
as an anonymous field where it could refer to some other 'n'.
struct bar {
int m;
char *buf __counted_by(n);
};
But I think an error would be useful here.
Martin
> >