Egcs 1.1.2 bug report
Nicholas P Lawes
nick@futurespager.co.uk
Wed Mar 24 08:35:00 GMT 1999
I have recently upgraded from egcs 1.1 to 1.1.2 on Linux and Solaris
and appear to have run into an internal compiler bug. The code compiled
on all platforms with the previous compiler, but now fails under Solaris
when using the -O2 optimisation flag.
Architecture : SparcStation 20, Solaris 2.6, configured with no options,
then 'make bootstrap'. The fault seems to occur in the if statement with
8 short-circuited strtok'd OR's.
Script started on Wed Mar 24 16:02:20 1999
[1 patina:nick pts/13 /rels/home/nick/bug> gcc -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
[2 patina:nick pts/13 /rels/home/nick/bug> gcc -c -O2 t.c
loop.c:1216: Internal compiler error in function reg_in_basic_block_p
[3 patina:nick pts/13 /rels/home/nick/bug> gcc -O -c t.c
[4 patina:nick pts/13 /rels/home/nick/bug>
script done on Wed Mar 24 16:03:00 1999
The code:-
#include <stdio.h>
#include <time.h>
#include <string.h>
typedef struct
{
char *data;
} BUF;
BUF *inputFiles;
char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
time_t now, readnow;
int
ReadLogLine(char *buf, int maxlen)
{
static FILE *fp;
char line[512];
while (1)
{
if (fp == NULL)
{
do
{
if (inputFiles == NULL)
exit(0);
if ((fp = fopen(inputFiles->data, "r")) == NULL)
perror(inputFiles->data);
BufDrop(&inputFiles);
}
while (fp == NULL);
}
while (1)
{
char *day, *month, *mday, *hh, *mm, *ss, *pid, *cp;
struct tm t;
struct tm *nowtm;
if (fgets(line, sizeof(line), fp) == NULL)
{
fclose(fp);
fp = NULL;
break; /* next file please */
}
buf[0] = '0';
stripcr(line);
if ((day = strtok(line, " :")) == NULL ||
(month = strtok(NULL, " :")) == NULL ||
(mday = strtok(NULL, " :")) == NULL ||
(hh = strtok(NULL, " :")) == NULL ||
(mm = strtok(NULL, " :")) == NULL ||
(ss = strtok(NULL, " :")) == NULL ||
(pid = strtok(NULL, " :")) == NULL ||
(cp = strtok(NULL, " :")) == NULL)
continue;
nowtm = localtime(&now);
memcpy(&t, nowtm, sizeof(t));
readnow = mktime(&t);
t.tm_hour = atoi(hh);
t.tm_min = atoi(mm);
t.tm_sec = atoi(ss);
t.tm_mday = atoi(mday);
t.tm_mon = (strstr(months, month) - months) / 3;
readnow = mktime(&t);
strncpy(buf + 1, cp, maxlen);
strcat(buf, "\n");
return strlen(buf);
}
}
return 0;
}
# Local Variables: #
# tab-width: 4 #
# End: #
--
Nick Lawes | BRB Associates Limited. | Tel : +44 171 626 3683
Internet : nick@grok.demon.co.uk | Fax : +44 171 410 0837
Ham : nick@gb7zhr.ampr.org | BBS : g8zhr@gb7hsn
More information about the Gcc-bugs
mailing list