https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102744
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |liuhongt at gcc dot gnu.org Last reconfirmed| |2021-10-14 Status|UNCONFIRMED |NEW Blocks| |102706 Target Milestone|--- |12.0 Keywords| |diagnostic Ever confirmed|0 |1 --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- Here's the relevant part of the test with line numbers: 68 char cbuf1[1 * sizeof (struct C)]; 69 char cbuf2[2 * sizeof (struct C)] = { }; 70 71 void test_C_global_buf (void) 72 { 73 struct C *p = (struct C*)&cbuf1; ... 84 p = (struct C*)&cbuf2; ... 90 p->b2.a[ 0].i = 0; 91 p->b2.a[ 1].i = 0; 92 p->b2.a[ 2].i = 0; // { dg-warning "\\\[-Warray-bounds" } 93 p->b2.a[ 3].i = 0; // { dg-warning "\\\[-Warray-bounds" } 94 sink (p); ad the output is below. We get the two -Warray-bounds instances as expected; they are issued before vectorization. Then we get an additional -Wstringop-overflow for the valid store on line 90 from the strlen pass thanks to the four stores having been vectorized. So the problem is basically the same as in one of the other reports. I hesistate to mark this a dupe only because it will need its own suppression (CC'ing Hongtao as a heads up). As an aside, these regressions will no doubt make the warnings pretty confusing to users. We (i.e., I) should try to come up with a fix before GCC 12 goes out the door. I don't expect to have the time to to get to it before stage 1 ends. /src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:92:10: warning: array subscript 2 is above array bounds of 'struct A[0]' [-Warray-bounds] 92 | p->b2.a[ 2].i = 0; // { dg-warning "\\\[-Warray-bounds" } | ~~~~~~~^~~~ /src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:10:28: note: while referencing 'a' 10 | struct B { int j; struct A a[0]; }; | ^ /src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:93:10: warning: array subscript 3 is above array bounds of 'struct A[0]' [-Warray-bounds] 93 | p->b2.a[ 3].i = 0; // { dg-warning "\\\[-Warray-bounds" } | ~~~~~~~^~~~ /src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:10:28: note: while referencing 'a' 10 | struct B { int j; struct A a[0]; }; | ^ /src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:90:17: warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] 90 | p->b2.a[ 0].i = 0; | ~~~~~~~~~~~~~~^~~ /src/gcc/master/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c:69:6: note: at offset 16 into destination object 'cbuf2' of size 16 69 | char cbuf2[2 * sizeof (struct C)] = { }; | ^~~~~ Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102706 [Bug 102706] [12 regression] -O2 vectorization causes regression in Warray-bounds-48.c on many targets