https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89149
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Status|UNCONFIRMED |NEW Last reconfirmed| |2019-02-07 CC| |msebor at gcc dot gnu.org Blocks| |56456, 55004 Ever confirmed|0 |1 --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed. The missing diagnostic isn't specific to C++ but also affects C. The problem is worse in C++ because it requires an error in the constexpr context. $ cat pr89149.c && gcc -O2 -S -Wall -Warray-bounds=2 -fdump-tree-optimized=/dev/stdout pr89149.c int f (void) { char a = (&(&(&"abc"[3])[-1])[-2])[5]; return a; } int g (void) { char a = (&(&(&"abc"[2])[-1])[-3])[4]; return a; } pr89149.c: In function ‘f’: pr89149.c:3:37: warning: array subscript 5 is outside array bounds of ‘char[4]’ [-Warray-bounds] 3 | char a = (&(&(&"abc"[3])[-1])[-2])[5]; | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ ;; Function f (f, funcdef_no=0, decl_uid=1906, cgraph_uid=1, symbol_order=0) f () { char a; int _3; <bb 2> [local count: 1073741824]: a_2 = MEM[(char *)"abc" + 5B]; _3 = (int) a_2; return _3; } ;; Function g (g, funcdef_no=1, decl_uid=1910, cgraph_uid=2, symbol_order=1) g () { <bb 2> [local count: 1073741824]: return 99; } Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004 [Bug 55004] [meta-bug] constexpr issues https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456 [Bug 56456] [meta-bug] bogus/missing -Warray-bounds