https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86691
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|missing -Warray-bounds due |missing -Warray-bounds on a |to early folding of |const array due to early |out-of-bounds accesses |folding of out-of-bounds | |accesses --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- No change in GCC 10. Here's a test case showing that the same accesses to non-const arrays are diagnosed. $ cat pr86691.c && gcc -O2 -Wall -S pr86691.c char a[2][3] = { "12", "123" }; const char b[2][3] = { "12", "123" }; int f (int i) { return i ? a[0][0] : a[7][9]; // -Warray-bounds (good) } int g (int i) { return i ? b[0][0] : b[7][9]; // missing -Warray-bounds (not good) } pr86691.c: In function ‘f’: pr86691.c:6:28: warning: array subscript 9 is above array bounds of ‘char[3]’ [-Warray-bounds] 6 | return i ? a[0][0] : a[7][9]; // -Warray-bounds (good) | ~~~~^~~