gcc Compiler Warning for O2: array subscript -2 is below array bounds of Idx2Freq_Tbl[]
Bug description
When compiling with OPTIM=2 or OPTIM=3 on gcc, we get multiple compiler warnings like
Compiling lib_enc/evs_enc_fx.c
In file included from lib_com/prot_fx.h:48,
from lib_enc/evs_enc_fx.c:8:
lib_enc/evs_enc_fx.c: In function 'evs_enc_fx':
lib_com/cnst.h:2734:67: warning: array subscript -2 is below array bounds of 'const Word16[]' {aka 'const short int[]'} [-Warray-bounds]
2734 | #define NS2SA_FX2(fs,x) (chk_fs(fs) mult((&Idx2Freq_Tbl[-2])[L_and(L_shr(fs,8),7)], (Word16)((x)/15625)))
| ~^~~~~~~~~~~~~~~~~~
lib_enc/evs_enc_fx.c:144:13: note: in expansion of macro 'NS2SA_FX2'
144 | delay = NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS );
| ^~~~~~~~~
lib_com/cnst.h:2729:21: note: while referencing 'Idx2Freq_Tbl'
2729 | extern const Word16 Idx2Freq_Tbl[];
|
Ways to reproduce
make OPTIM=3