[Bug target/18977] [4.0 regression] LAPACK test xeigtsts segfaults with optimization

Thomas dot Koenig at online dot de gcc-bugzilla@gcc.gnu.org
Fri Jan 28 14:29:00 GMT 2005


------- Additional Comments From Thomas dot Koenig at online dot de  2005-01-28 14:29 -------
The inner loop does not terminate in this example,
until a segfault is hit.

$ cat sl5-error.c
#include <stdio.h>

void foo(float * x);

int main()
{
  float x[4];
  foo (x);
  return 0;
}

void foo (float *x)
{
    int i,j,k;
    float temp;
    static float t16[16]={1.,2.,3.,4.,5.,6.,7.,8.,9.,
                          10.,11.,12.,13.,14.,15.,16.};
    static float tmp[4]={0.,0.,0.,0.};

    for (i=0; i<4; i++) {
        k = 3 - i;
        temp = t16[5*k];
        for(j=k+1; j<4; j++) {
            printf("i=%d, j=%d, k=%d\n",i,j,k);
            tmp[k] = t16[k+  j*4] * temp;
        }
    }
    x[0] = tmp[0];
    x[1] = tmp[1];
    x[2] = tmp[2];
    x[3] = tmp[3];
}
$ gcc sl5-error.c
$ ./a.out
i=1, j=3, k=2
i=2, j=2, k=1
i=2, j=3, k=1
i=3, j=1, k=0
i=3, j=2, k=0
i=3, j=3, k=0
$ gcc -O1 sl5-error.c
$ ./a.out
i=1, j=3, k=2
i=2, j=2, k=1
i=2, j=3, k=1
i=2, j=4, k=1
i=2, j=5, k=1
i=2, j=6, k=1

... and so on, until

i=2, j=803, k=1
i=2, j=804, k=1
i=2, j=805, k=1
i=2, j=806, k=1
i=2, j=807, k=1
i=2, j=808, k=1
Segmentation fault
$ gcc -v ; gcc -dumpmachine
Using built-in specs.
Configured with: ../gcc-4.0-20050123/configure --prefix=/home/zfkts
--enable-languages=c,f95
Thread model: posix
gcc version 4.0.0 20050123 (experimental)
ia64-unknown-linux-gnu


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18977



More information about the Gcc-bugs mailing list