[Bug c/109233] warning: array subscript 5 is above array bounds of ‘struct tg3_napi[5]’ since r12-2591

2023-03-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109233

Jakub Jelinek  changed:

   What|Removed |Added

Summary|warning: array subscript 5  |warning: array subscript 5
   |is above array bounds of|is above array bounds of
   |‘struct tg3_napi[5]’|‘struct tg3_napi[5]’ since
   ||r12-2591
 CC||jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek  ---
Both the original and minimized testcase started to warn with
r12-2591-g2e96b5f14e4025691b57d2301d71a

[Bug c/109233] warning: array subscript 5 is above array bounds of ‘struct tg3_napi[5]’

2023-03-22 Thread ubizjak at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109233

--- Comment #3 from Uroš Bizjak  ---
Created attachment 54729
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54729=edit
Minimized testcase

WIP, but *substantially* minimized.

gcc -O2 -Warray-bounds:

tg3-6.c: In function ‘tg3_init_one’:
tg3-6.c:51:37: warning: array subscript 5 is above array bounds of ‘struct
tg3_napi[5]’ [-Warray-bounds=]
   51 |   struct tg3_napi *tnapi = >napi[i];
  | ^~~
tg3-6.c:22:19: note: while referencing ‘napi’
   22 |   struct tg3_napi napi[(4 + 1)];
  |   ^~~~
tg3-6.c:51:37: warning: array subscript 5 is above array bounds of ‘struct
tg3_napi[5]’ [-Warray-bounds=]
   51 |   struct tg3_napi *tnapi = >napi[i];
  | ^~~
tg3-6.c:22:19: note: while referencing ‘napi’
   22 |   struct tg3_napi napi[(4 + 1)];
  |   ^~~~

[Bug c/109233] warning: array subscript 5 is above array bounds of ‘struct tg3_napi[5]’

2023-03-21 Thread ubizjak at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109233

--- Comment #2 from Uroš Bizjak  ---
As can be seen from the preprocessed file, tp->irq_max is set to:

 tp->irq_max = 1;

or

   tp->irq_max = (4 + 1);

and the compilation warns in tg3_init_one at:

 for (i = 0; i < tp->irq_max; i++) {
  struct tg3_napi *tnapi = >napi[i];

[Bug c/109233] warning: array subscript 5 is above array bounds of ‘struct tg3_napi[5]’

2023-03-21 Thread ubizjak at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109233

--- Comment #1 from Uroš Bizjak  ---
Created attachment 54719
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54719=edit
Preprocessed file

-O2 -Warray-bounds:

In function ‘tg3_init_one’,
inlined from ‘tg3_init_one’ at
drivers/net/ethernet/broadcom/tg3.c:17542:12:
drivers/net/ethernet/broadcom/tg3.c:17787:37: warning: array subscript 5 is
above array bounds of ‘struct tg3_napi[5]’ [-Warray-bounds=]
In file included from drivers/net/ethernet/broadcom/tg3.c:72:
drivers/net/ethernet/broadcom/tg3.h: In function ‘tg3_init_one’:
drivers/net/ethernet/broadcom/tg3.h:3203:18: note: while referencing ‘napi’
In function ‘tg3_init_one’,
inlined from ‘tg3_init_one’ at
drivers/net/ethernet/broadcom/tg3.c:17542:12:
drivers/net/ethernet/broadcom/tg3.c:17787:37: warning: array subscript 5 is
above array bounds of ‘struct tg3_napi[5]’ [-Warray-bounds=]
drivers/net/ethernet/broadcom/tg3.h: In function ‘tg3_init_one’:
drivers/net/ethernet/broadcom/tg3.h:3203:18: note: while referencing ‘napi’