Date: Mon, 1 Mar 93 12:40:03 EST From: ronis AT onsager DOT chem DOT mcgill DOT ca (David Ronis) To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Bug with -funroll-loops in gcc Hi DJ, I have finally isolated a small code fragment that causes gcc to crash on my PC when I turn on -funroll-loops. The following when compiled with: gcc -O2 -m486 -funroll-loops -c test.c will crash with a segmentation violation (specifically, in pointer 0x00000000 at 40:819ea, exception 14 (0xe) at eip=819ea). Removing the -funroll-loops flag "fixes" the problem. Note, that I use this flag eleswhere without any problem. Thanks in advance. David Ronis -----------------------------------Cut Here------------------------------------ #include <stdio.h> #define MAXMOMENTS 2 extern unsigned int nmonomer; extern unsigned long count; extern double *moment[]; extern int ivers; void dump_run(string) char *string; { FILE *outstream; unsigned int i,j; float tmp[MAXMOMENTS+2]; outstream=fopen("mmonte","wb"); for(i=1;i<=nmonomer;i++){ tmp[0]=i; for(j=0;j<MAXMOMENTS;j++) tmp[j+1]=(moment[j][i]/(double)count); tmp[MAXMOMENTS+1]=(tmp[1]-tmp[0]*tmp[0]); fwrite(tmp,sizeof(float),MAXMOMENTS+2,outstream); } fclose(outstream); }