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

Tavian Barnes via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 07:54:27 PDT 2024


tavianator wrote:

For the record, I think the most correct definition, in terms of "this is how much memory you should allocate for a struct with a flexible array member" is this:

```c
max(
    sizeof(struct S),      // always at least the size of the struct itself
    round_up(
        alignof(struct S), // size must be a multiple of alignment
        offsetof(struct S, fam) + count * sizeof(((struct S *)0)->fam[0])
    )
)
```

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


More information about the cfe-commits mailing list