[clang] [Clang] Fix __builtin_dynamic_object_size off by 4 (PR #111015)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 12:28:43 PDT 2024
efriedma-quic wrote:
The value clang computes is the difference between the address of the beginning of the struct, and the end of the array (or the end of the struct, if the array fits in the padding). The value gcc computes is that, plus the offset between the beginning of the array and the end of the struct. So the formula used by gcc is adding unused padding after the end of every flexible array.
My default stance would be that gcc and the Linux code in question are wrong. We could reconsider if strict checking is impractical for Linux, but I'd expect kernel devs to prefer catching accesses one past the end of the array.
https://github.com/llvm/llvm-project/pull/111015
More information about the cfe-commits
mailing list