https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91463
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Component|c |middle-end Resolution|--- |FIXED Target Milestone|--- |10.0 --- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> --- GCC 10 now issues the following warning for the test case in comment #0: pr91463.c: In function ‘f’: pr91463.c:7:6: warning: array subscript 666 is above array bounds of ‘int[0]’ [-Warray-bounds] 7 | s.a[666] = 0; // missing -Warray-bounds | ~~~^~~~~ pr91463.c:1:19: note: while referencing ‘a’ 1 | struct S { int n, a[]; }; | ^ pr91463.c:3:10: note: defined here ‘s’ 3 | struct S s = { 2, { 1, 0 } }; | ^ I agree that some of these problems can be detected earlier. It might be worth moving some of the -Warray-bounds code out of tree-vrp.c and into some utility function that could be called by earlier passes, or even by the front-ends without optimization, to detect the basic problems. I'll keep that in mind as a possible future project.