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

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
We would need to see the original code (the translation unit) to tell for sure
why the warning is only issued on some targets and not on others, but the most
likely answer is that the code results in different internal representation,
and GCC can reliably detect problems only in some and not in others.

I don't think this type of -Warray-bounds warning (the one for direct array
accesses as opposed to the one for library functions) detects out-of-bounds
accesses in dynamically allocated memory yet so I wouldn't expect to see it for
the snippet you showed in comment #5, regardless of what the access looks like.

The warning still only detects such accesses to declared objects but those
don't make it possible to initialize trailing arrays with more than the
declared number of elements.  The only kind of a trailing array that can be
initialized to more elements than its bound suggests in a declared object is a
C99 flexible array member (as a GCC extension).  Neither zero-length arrays nor
arrays of length 1 can be initialized with excess elements.  Of those, only
zero-length arrays are supported as "flexible array members."  Treating
trailing arrays of length 1 the same is discouraged.  See
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html for details.

Reply via email to