[Bug middle-end/101836] __builtin_object_size(P->M, 1) where M is an array and the last member of a struct fails
msebor at gcc dot gnu.org
Mon Jun 13 14:48:17 GMT 2022
--- Comment #18 from Martin Sebor <msebor at gcc dot gnu.org> ---
The zero size case exists (and is documented) solely as a substitute for
flexible array members. Treating is as an ordinary array would disable that
extension. It might be appropriate to provide a separate option to control it
but conflating it with the other cases (one or more elements) doesn't seem like
the robust design.
As I mentioned in the review of the Clang change,
https://reviews.llvm.org/D126864, so that code bases that use some larger
number of elements than zero, such as one, and that can't easily change, can
still benefit from the BOS enhancement for the remaining cases, it would be
helpful for the new option to accept the minimum number of elements at which a
trailing array ceases to be considered a poor-man's flexible array member.
More information about the Gcc-bugs