https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82455
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The patch referenced in comment #1 was rejected but the -Wrestrict/-Warray-bounds enhancement committed in r242366 detects the bugs in the test case in comment #0 (see below). The enhancement detects but a subset of the bugs the patch in comment #1 was able to detect but I'll resolve this as fixed and open new bugs for the remaining cases. pr82455.c: In function ‘fcst’: pr82455.c:5:3: warning: array subscript 3 is above array bounds of ‘char[2]’ [-Warray-bounds] __builtin_strcpy (d, a + 3); // -Warray-bounds (good) ^~~~~~~~~~~~~~~~~~~~~~~~~~~ pr82455.c:5:3: warning: ‘__builtin_strcpy’ offset 3 is out of the bounds [0, 2] of object ‘a’ with type ‘char[2]’ [-Warray-bounds] pr82455.c:3:8: note: ‘a’ declared here char a[2] = "0"; ^ pr82455.c: In function ‘frng’: pr82455.c:16:3: warning: ‘__builtin_strcpy’ offset [3, 2147483647] is out of the bounds [0, 2] of object ‘a’ with type ‘char[2]’ [-Warray-bounds] __builtin_strcpy (d, a + i); // both warnings missing ^~~~~~~~~~~~~~~~~~~~~~~~~~~ pr82455.c:11:8: note: ‘a’ declared here char a[2] = "0"; ^