Testcase (derived from ffmpeg):
void av_solve_lls(double (*factor)[33], int count, int min_order){
int i,j,k;
for(i=0; i<count; i++){
for(j=i; j<count; j++){
double sum = factor[i][j];
for(k=i-1; k>=0; k--)
sum -= factor[i][k]*factor[j][k];
factor[i][i]= sum;
}
}
for(j=count-1; j>=min_order; j--){
for(i=j; i>=0; i--){
factor[0][j]= 0;
}
factor[0][j] = 0;
for(i=0; i<=j; i++){
factor[0][j] += 0;
}
}
}
With the following command-line:
gcc l.c -S -Wall -O2
Gives the following warning:
/tmp/l.c: In function av_solve_lls:
/tmp/l.c:18:18: warning: array subscript is below array bounds
Using gcc 4.5.0 on x86-64-pc-linux-gnu, built from source, configured with
"configure --enable-languages=c --disable-bootstrap".
The testcase is a little large, but I can't figure out how to reduce it more;
the issue seems very sensitive to the precise structure of the code.
--
Summary: Bogus "array subscript is below array bounds" with loops
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: eli dot friedman at gmail dot com
GCC host triplet: x86-64-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44848