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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to