https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90752
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |12.0 Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- GCC 12 warns as expected: $ gcc -O2 -S -Wall pr90752.c pr90752.c: In function ‘f’: pr90752.c:7:11: warning: array subscript -1 is outside array bounds of ‘char[4]’ [-Warray-bounds] 7 | return p[-1]; // missing -Warray-bounds | ~^~~~ pr90752.c:2:13: note: at offset -1 into object ‘a’ of size 4 2 | extern char a[4]; | ^ pr90752.c: In function ‘g’: pr90752.c:13:11: warning: array subscript [-5, -2] is outside array bounds of ‘char[4]’ [-Warray-bounds] 13 | return p[-5]; // missing -Warray-bounds | ~^~~~ pr90752.c:2:13: note: at offset [-5, -2] into object ‘a’ of size 4 2 | extern char a[4]; | ^ pr90752.c: In function ‘h’: pr90752.c:19:11: warning: array subscript 4 is outside array bounds of ‘char[4]’ [-Warray-bounds] 19 | return p[4]; // missing -Warray-bounds | ~^~~ pr90752.c:2:13: note: at offset 4 into object ‘a’ of size 4 2 | extern char a[4]; | ^