Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Brian Donnell [PT4]
Fri, 10 Apr 1992 19:20
GCC 2.1 Optimizer Bug
Author: Brian Donnell [PT4]
Date: Fri, 10 Apr 1992 19:20
Date: Fri, 10 Apr 1992 19:20
64 lines
1796 bytes
1796 bytes
The program below when compiled with the command:
gcc -o foo -O foo.c
generates the following output on a Sun/Sparc with SunOS 4.1.1
(I am using GCC 2.1)
8941 837 1013
1903521977 768 1013
1903521766 557 1013
1886547925 544 1013
When compiled without the -O option, it generates the correct output:
1903521977 768 1013
1903521977 768 1013
1903521766 557 1013
1886547925 544 1013
Brian Donnell
NASA/JSC
File foo.c contents:
#include <stdio.h>
void main(void);
static int HashSymbol(char *,int);
void main()
{
HashSymbol("quoxnar",1013);
HashSymbol("quoxnar",1013);
HashSymbol("progn",1013);
HashSymbol("progn",1013);
}
static int HashSymbol(word,range)
char *word;
int range;
{
register int k,j,i;
register int length;
int tally;
unsigned long count = 0L,tmpLong;
char *tmpPtr;
tmpPtr = (char *) &tmpLong;
for (length = 0; word[length]; length++);
length = length / sizeof(unsigned long);
for (i = 0 , j = 0 ; i < length; i++)
{
for (k = 0 ; k < sizeof(unsigned long) ; k++ , j++)
tmpPtr[k] = word[j];
count += tmpLong;
}
for (word = (char *) &word[j]; *word; word++) count += (unsigned long) *word;
tally = (int) (count % range);
printf("%lu %d %d\n",count,tally,range);
if (tally < 0) return(-tally);
return(tally);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads