[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

Jan Hendrik Farr via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 17:19:17 PDT 2024


Cydox wrote:

The expression can be simplified to:

```C
round_up(
    alignof(struct S)
    offsetof(struct S, fam) + count * sizeof(((struct S *)0)->fam[0])
)
```
As the padding at the end of the structure is always smaller than the alignof.
So `round_up(alignof(struct S), offsetof(struct S, fam)) = sizeof(struct S)`

https://github.com/llvm/llvm-project/pull/112636


More information about the cfe-commits mailing list