https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48560
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic CC| |msebor at gcc dot gnu.org Known to work| |4.5.3, 5.1.0 Blocks| |56456 Resolution|WONTFIX |FIXED Known to fail| |4.7.4 --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- The code is diagnosed by recent versions of GCC: $ cat pr48560.c && gcc -O2 -S -Wall pr48560.c char foo1 (int i) { static char s[] = "foo"; switch (i) { case 30: return s[30]; } return s[i]; } pr48560.c: In function ‘foo1’: pr48560.c:8:13: warning: array subscript 30 is above array bounds of ‘char[4]’ [-Warray-bounds] return s[30]; ~^~~~ Bisection points to r213045 (gcc 5.1.0) as the commit that restored the warning. Let me add the test case to the test suite and change the resolution to fixed. r213045 | rguenth | 2014-07-25 03:44:57 -0400 (Fri, 25 Jul 2014) | 22 lines 2014-07-25 Richard Biener <rguent...@suse.de> PR middle-end/61762 PR middle-end/61894 * fold-const.c (native_encode_int): Add and handle offset parameter to do partial encodings of expr. (native_encode_fixed): Likewise. (native_encode_real): Likewise. (native_encode_complex): Likewise. (native_encode_vector): Likewise. (native_encode_string): Likewise. (native_encode_expr): Likewise. * fold-const.c (native_encode_expr): Add offset parameter defaulting to -1. * gimple-fold.c (fold_string_cst_ctor_reference): Remove. (fold_ctor_reference): Handle all reads from tcc_constant ctors. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456 [Bug 56456] [meta-bug] bogus/missing -Warray-bounds