Issue 145712
Summary counted_by cannot be used with C23 attribute syntax
Labels new issue
Assignees
Reporter tavianator
    [The docs](https://clang.llvm.org/docs/AttributeReference.html#counted-by-counted-by-or-null-sized-by-sized-by-or-null) claim that `counted_by` has a C23 attribute syntax equivalent of `[[clang::counted_by(...)]]`.  However:

```console
tavianator@graphene$ cat foo.c
struct foo {
        int n;
        int a[] [[clang::counted_by(n)]];
};

struct bar {
        int n;
        int a[] __attribute__((counted_by(n)));
};
tavianator@graphene$ clang -fsyntax-only foo.c
foo.c:3:12: error: 'counted_by' attribute cannot be applied to types
    3 |         int a[] [[clang::counted_by(n)]];
      | ^
1 error generated.
tavianator@graphene$ clang -v
clang version 20.1.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/15.1.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to