[Bug tree-optimization/102151] Spurious warning by -Warray-bounds when allocating with flexible array member

gniibe at fsij dot org gcc-bugzilla@gcc.gnu.org
Thu Sep 2 02:34:38 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102151

--- Comment #4 from Niibe Yutaka <gniibe at fsij dot org> ---
Thank you for the explanation.  I understand how (current version of) GCC
warns.

>From the viewpoint of use of structure with flexible array member, still, this
could be considered as a bug of GCC, because the warning itself is irrelevant.

My point is that:

(1) In the test case, use of offsetof(struct arg_and_data_s, arg) is valid (I
mean, no violation of language/feature).  In other words,

(2) Allocated space for an object of the structure may be smaller than
sizeof().  There are such cases, for structure with flexible array member,
because of structure alignment.

(3) It seems for me that by (current version of) GCC, the fact (2) is ignored.


More information about the Gcc-bugs mailing list