On Tue, Feb 10, 2026 at 12:41 AM Arnd Bergmann <[email protected]> wrote:
>
> On Fri, Nov 21, 2025, at 20:39, Bill Wendling wrote:
> >
> > +/*
> > + * Optional: only supported since clang >= 21
> > + *
> > + * clang: https://github.com/llvm/llvm-project/pull/137250
> > + */
> > +#ifdef CONFIG_CC_HAS_COUNTED_BY_FOR_POINTER
> > +#define __counted_by_ptr(member)     
> > __attribute__((__counted_by__(member)))
> > +#else
> > +#define __counted_by_ptr(member)
> > +#endif
>
> Something changed in recent gcc versions. I had tested gcc-16.0.1
> successfully with CONFIG_CC_HAS_COUNTED_BY_PTR=y, but after upgrading
> to a recent git snapshot, I get this output:
>
> fs/coredump.c:95:15: error: 'counted_by' attribute is not allowed for a 
> non-array field
>    95 |         char *corename __counted_by_ptr(size);
>       |               ^~~~~~~~
> drivers/misc/lkdtm/bugs.c:518:15: error: 'counted_by' attribute is not 
> allowed for a non-array field
>   518 |         char *buf __counted_by_ptr(len);
>       |               ^~~
> drivers/misc/lkdtm/bugs.c:520:29: error: 'counted_by' attribute is not 
> allowed for a non-array field
>   520 |         struct lkdtm_extra *extra __counted_by_ptr(nr_extra);
>       |                             ^~~~~
>
> This is every use of __counted_by_ptr() in linux-next at the moment.
>
I assume it's a git snapshot of GCC. :-) What does
`scripts/cc-version.sh` produce for it?

-bw

Reply via email to