https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91631
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED Target Milestone|--- |10.0 --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- Partially fixed in r275981. The test case triggers the six warnings below (the output with -D_FORTIFY_SOURCE=2 is similar). What's not "fixed" is that the warning for buffer overflow is supposed to be -Wstringop-overflow (and with _FORTIFY_SOURCE the overflow should cause an abort). But that's a separate problem. pr91631.c: In function ‘efa’: pr91631.c:11:3: warning: ‘strcpy’ offset 3 from the object at ‘es’ is out of the bounds of referenced subobject ‘a’ with type ‘char[3]’ at offset 0 [-Warray-bounds] 11 | strcpy (es[0].a, a); // missing warning | ^~~~~~~~~~~~~~~~~~~ pr91631.c:3:17: note: subobject ‘a’ declared here 3 | struct S { char a[3], b[5], c[]; }; | ^ pr91631.c: In function ‘efb’: pr91631.c:17:3: warning: ‘strcpy’ offset 8 from the object at ‘es’ is out of the bounds of referenced subobject ‘b’ with type ‘char[5]’ at offset 3 [-Warray-bounds] 17 | strcpy (es[0].b, a); // missing warning | ^~~~~~~~~~~~~~~~~~~ pr91631.c:3:23: note: subobject ‘b’ declared here 3 | struct S { char a[3], b[5], c[]; }; | ^ pr91631.c: In function ‘efc’: pr91631.c:23:3: warning: ‘strcpy’ offset [8, 11] from the object at ‘es’ is out of the bounds of referenced subobject ‘c’ with type ‘char[]’ at offset 8 [-Warray-bounds] 23 | strcpy (es[0].c, a); // missing warning | ^~~~~~~~~~~~~~~~~~~ pr91631.c:3:29: note: subobject ‘c’ declared here 3 | struct S { char a[3], b[5], c[]; }; | ^ pr91631.c: In function ‘ifa’: pr91631.c:29:3: warning: ‘strcpy’ offset 3 from the object at ‘is’ is out of the bounds of referenced subobject ‘a’ with type ‘char[3]’ at offset 0 [-Warray-bounds] 29 | strcpy (is[0].a, a); // warning (good) | ^~~~~~~~~~~~~~~~~~~ pr91631.c:3:17: note: subobject ‘a’ declared here 3 | struct S { char a[3], b[5], c[]; }; | ^ pr91631.c: In function ‘ifb’: pr91631.c:35:3: warning: ‘strcpy’ offset 8 from the object at ‘is’ is out of the bounds of referenced subobject ‘b’ with type ‘char[5]’ at offset 3 [-Warray-bounds] 35 | strcpy (is[0].b, a); // warning (good) | ^~~~~~~~~~~~~~~~~~~ pr91631.c:3:23: note: subobject ‘b’ declared here 3 | struct S { char a[3], b[5], c[]; }; | ^ pr91631.c: In function ‘ifc’: pr91631.c:41:3: warning: ‘strcpy’ offset [8, 11] from the object at ‘is’ is out of the bounds of referenced subobject ‘c’ with type ‘char[]’ at offset 8 [-Warray-bounds] 41 | strcpy (is[0].c, a); // missing warning | ^~~~~~~~~~~~~~~~~~~ pr91631.c:3:29: note: subobject ‘c’ declared here 3 | struct S { char a[3], b[5], c[]; }; | ^