https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97391
Bug ID: 97391 Summary: [11 Regression] bogus -Warray-bounds accessing a multidimensional array parameter Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Both warnings below are incorrect. $ cat xx.c && gcc -O2 -S -Wall xx.c void f (char a[3][5]) { for (int i = 0; i < 3; i++) for (int j = 0; j < 5; j++) a[i][j] = 0; } xx.c: In function ‘f’: xx.c:5:8: warning: array subscript ‘char[5][0]’ is partly outside array bounds of ‘char[3]’ [-Warray-bounds] 5 | a[i][j] = 0; | ~^~~ xx.c:1:14: note: while referencing ‘a’ 1 | void f (char a[3][5]) | ~~~~~^~~~~~~ xx.c:5:15: warning: ‘__builtin_memset’ forming offset [3, 14] is out of the bounds [0, 3] [-Warray-bounds] 5 | a[i][j] = 0; | ~~~~~~~~^~~