optimization/10087: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array
bangerth@dealii.org
bangerth@dealii.org
Fri Mar 14 23:59:00 GMT 2003
Old Synopsis: optimizer produces wrong code when indexing malloc'ed 2D array
New Synopsis: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Mar 14 23:45:17 2003
State-Changed-Why:
Confirmed also on x86 linux. Here's a slightly modified example:
--------------------------
void b(int*,int*);
typedef struct {
double T1;
char c;
} S;
int main(void)
{
int i,j;
double s;
S x1[2][2];
S *x[2] = { x1[0], x1[1] };
S **E = x;
for( i=0; i < 2; i++ )
for( j=0; j < 2; j++ )
E[j][i].T1 = 1;
for( i=0; i < 2; i++ )
for( j=0; j < 2; j++ )
s = E[j][i].T1;
b(&j,&i);
printf( "result %.6e\n", s);
return 0;
}
void b(int *i, int *j) {}
-------------------------------
This yields different results with and without -O2:
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc x.c
g/x> ./a.out
result 1.000000e+00
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc x.c -O2
g/x> ./a.out
result 2.171654e+00
The same holds for 3.3, but 3.2.2 is ok, so it's a regression.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10087
More information about the Gcc-bugs
mailing list