[clang] [Clang] Fix __builtin_dynamic_object_size off by 4 (PR #111015)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 4 10:04:19 PDT 2024
efriedma-quic wrote:
The point of __counted_by is precisely to supplement the normal standard rules: specifically, if you have counted_by, the size of the flexible array is precisely the size specified by the attribute. Not whatever size is implied by the access. Otherwise, it would be illegal for __bdos to use the counted_by attribute at all. The size of the array can't change based on how __bdos is queried.
`sizeof(struct s) + p->count * sizeof(*p->array))` is a weird compromise: it's not unbounded, but it's larger than the size specified by the standard.
https://github.com/llvm/llvm-project/pull/111015
More information about the cfe-commits
mailing list