https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116016

--- Comment #50 from Alejandro Colomar <alx at kernel dot org> ---
I forgot to set:

> That is, __lengthof__ should be useful in all of the following cases:
> 
>     #define memberof(T, m)  (((T *) NULL)->m)
> 
>     struct s {
>         size_t n;
>         int fam[] __attribute__((counted_by(n)));
>     };
> 
>     __attribute__((access(read_only, 3, 4)))
>     void
>     f(size_t n1, int p[n1], int q[], size_t n2)
>     {
>         int       a[3];
>         size_t    m;
>         struct s  *s;
> 
>         m = offsetof(struct s, fam) + sizeof(memberof(struct s, fam)[0]) * 7;
>         s = malloc(m);

          s->n = m;

> 
>         assert(__lengthof__(a) == 3);
>         assert(__lengthof__(p) == n1);
>         assert(__lengthof__(q) == n2);
>         assert(__lengthof__(memberof(struct s, fam)) == m);
>     }

Reply via email to