https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106247
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |WAITING Last reconfirmed|2022-07-10 00:00:00 |2022-08-19 Ever confirmed|0 |1 CC| |msebor at gcc dot gnu.org --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- This instance of -Warray-bounds (with the text "partly outside the bounds") is often issued for aliasing violations where an object of one type is being access by an lvalue of a larger struct. The ultimate access may be to a member of the larger struct whose offset is within the bounds of the smaller object, but the access is (or could be) wrong nonetheless (due to the aliasing rules) and hence the warning. Here's an example: $ cat a.c && gcc -O2 -S -Wall a.c struct A { int i; }; struct B { struct A a; int j; }; void* f (void) { struct A *p = __builtin_malloc (sizeof *p); ((struct B*)p)->a.i = 0; return p; } a.c: In function ‘f’: a.c:7:17: warning: array subscript ‘struct B[0]’ is partly outside array bounds of ‘unsigned char[4]’ [-Warray-bounds] 7 | ((struct B*)p)->a.i = 0; | ^~ a.c:6:17: note: object of size 4 allocated by ‘__builtin_malloc’ 6 | struct A *p = __builtin_malloc (sizeof *p); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ If your case is comparable this should be resolved as invalid; otherwise, if it's substantially different please post a reproducible test case.