https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101671
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Last reconfirmed| |2021-07-29 Keywords| |diagnostic Summary|pr83510 fails because |pr83510 fails with -Os |threader confuses |because threader confuses |-Warray-bounds |-Warray-bounds Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- Confirmed. I've extracted the test case that fails from the bigger test. Rather than xfailing the whole test I think it would be better to split out just the failing case and/or xfail just that assertion. Unless you expect the others to start failing too due to some changes you still have planned? $ cat a.c && gcc -Os -S -Wall a.c extern int f (void); extern void sink (unsigned int); unsigned int a[10]; static unsigned int g (int i, int j) { if (i == 9) return j; else if (i == 10) return a[i]; // no warning here return 0; } void test_g (int j) { for (int i = 0; i < 10; i++) { if (f ()) sink (g (i, j)); } } static unsigned int h (int i, int j) { switch (i) { case 9: return j; case 10: return a[i]; // { dg-bogus "-Warray-bounds" } } return 0; } void test_h (int j) { for (int i = 0; i < 10; i++) { if (f ()) sink (h (i, j)); } } In function ‘h’, inlined from ‘test_h’ at a.c:41:2: a.c:31:15: warning: array subscript 10 is above array bounds of ‘unsigned int[10]’ [-Warray-bounds] 31 | return a[i]; // { dg-bogus "-Warray-bounds" } | ~^~~ a.c: In function ‘test_h’: a.c:4:14: note: while referencing ‘a’ 4 | unsigned int a[10]; | ^