Path: utzoo!telly!ddsw1!lll-winken!killer!osu-cis!tut.cis.ohio-state.edu!moose.cita.toronto.edu!trq From: trq@moose.cita.toronto.edu (Tom Quinn) Newsgroups: gnu.gcc.bug Subject: bug in sparc gcc 1.28 Message-ID: <8809261533.AA28244@moose.cita.toronto.edu> Date: 26 Sep 88 15:33:42 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 262 The following code will cause gcc to get a fatal signal when compile with "-O". This is gcc version 1.28 on a Sun4/110 running SunOs 4.0. Tom Quinn Canadian Institute for Theoretical Astrophysics trq@moose.cita.toronto.edu SOON TO BE trq@moose.cita.utoronto.ca UUCP - decvax!utgpu!moose!trq BITNET - quinn@utorphys.bitnet ARPA - trq%moose.cita.toronto.edu@relay.cs.net The compile: gcc -g -v -O -sun4 -c control.c gcc version 1.28 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dsparc -Dsun -Dunix -D__OPTIMIZE__ control.c /tmp/cca04551.cpp GNU CPP version 1.28 /usr/local/lib/gcc-cc1 /tmp/cca04551.cpp -quiet -dumpbase control.c -g -O -version -o /tmp/cca04551.s GNU C version 1.28 (sparc) compiled by GNU C version 1.28. gcc: Program cc1 got fatal signal 6. The code: ------------------------------------------------------------------------ void push(), push_dstack() ; typedef struct { int nitem; char **i_list; } TOK_LIST; typedef union yystype { char charval[80 ]; float floatval; TOK_LIST *t_list; }; extern union yystype yylval; typedef struct { char d_name[40]; int (*dev_setup)(), (*dev_enable)(), (*dev_idle)(), (*dev_close)() ; } DEVICES; extern DEVICES devices[]; extern int devnum, ndev; char *malloc(), *sprintf(), *strncat(); static char buff[2000 + 1], word[80 ]; char *mgets(); static int graph_mode = 0 ; typedef struct yyltype { int last_column; char *text; } yyltype; static char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6 }; static short yyr1[] = { 0, 112, 112, 113, 113, 113, 113, 113, 113, 113, 113 }; static short yyr2[] = { 0, 1, 1, 0, 1 }; static short yydefact[] = { 1, 43, 142, 0, 0 }; static short yydefgoto[] = { 1, 74 }; static short yypact[] = {-32768, -32768,-32768, 456,-32768 }; static short yypgoto[] = {-32768, 198 }; static short yytable[] = { 92, 0, 0, 0, 249 }; static short yycheck[] = { 26, -1, -1, -1, 109 }; int yychar; union yystype yylval; yyltype yylloc; int yyparse() { register int yystate; register int yyn; register short *yyssp; register union yystype *yyvsp; yyltype *yylsp; int yyerrstatus; int yychar1; short yyssa[200 ]; union yystype yyvsa[200 ]; yyltype yylsa[200 ]; short *yyss = yyssa; union yystype *yyvs = yyvsa; yyltype *yyls = yylsa; union yystype yyval; int yylen; yystate = 0; yyerrstatus = 0; yychar = -2 ; yyssp = yyss - 1; yyvsp = yyvs; yylsp = yyls; yynewstate: *++yyssp = yystate; yyn = yypact[yystate]; if (yyn == -32768 ) goto yydefault; if (yychar == -2 ) { yychar = yylex() ; } if (yychar <= 0) { yychar1 = 0; yychar = 0 ; } else { yychar1 = ((unsigned)(yychar) <= 346 ? yytranslate[yychar] : 134) ; } yyn += yychar1; if (yyn < 0 || yyn > 1184 || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; if (yyn == 454 ) return(0) ; if (yychar != 0 ) yychar = -2 ; *++yyvsp = yylval; *++yylsp = yylloc; if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; yylen = yyr2[yyn]; yyval = yyvsp[1-yylen]; switch (yyn) { case 30: { int i; if(graph_mode) (*devices[devnum].dev_idle) (); (*devices[devnum].dev_close) (); (void)sprintf(buff,"%s",yyvsp[0].charval); (void)mgets(word,80 ); (void)strncat(buff,word,2000 ); for(i = 0;i < ndev;i++) { if(strcmp(devices[i].d_name,yyvsp[0].charval) == 0) { devnum = i; break; } } if(i < ndev) { if( (*devices[devnum].dev_setup) (word) < 0) { msg_1s("No such device %s\n",buff); devnum = 0 ; } } else { devnum = 1 ; if( (*devices[devnum].dev_setup) (buff) != 0) { msg_1s("No such device %s\n",buff); devnum = 0 ; } } set_dev(); (*devices[devnum].dev_enable) (); graph_mode = 1; ; break;} case 31: { char *do_loop; register int i,j,k; if(yyvsp[-8].charval[0] == '\0' || yyvsp[-1].t_list == 0 ) { freelist(yyvsp[-1].t_list); break; } if(yyvsp[-1].t_list->nitem <= 0) { msg_1s("DO %s command list is empty\n",yyvsp[-8].charval); freelist(yyvsp[-1].t_list); break; } if((do_loop = malloc(2000 + 1)) == 0 ) { msg_1s("Can't allocate space for DO %s\n",yyvsp[-8].charval); freelist(yyvsp[-1].t_list); break; } j = 0; for(i = 0;i < yyvsp[-1].t_list->nitem;i++) { for(k = 0;k < 80 && j < 2000 ;j++,k++) { if((do_loop[j] = yyvsp[-1].t_list->i_list[i][k]) == '\0') { do_loop[j++] = ' '; break; } } } if(j == 2000 ) { msg_1d("Maximum length of a DO loop is %d\n",2000 ); } do_loop[j-1] = '\n'; do_loop[j] = '\0'; push_dstack(yyvsp[-8].charval,yyvsp[-6].floatval,yyvsp[-4].floatval,yyvsp[-3].floatval); if(next_do() == 0) { push(do_loop,1 ); } freelist(yyvsp[-1].t_list); ; break;} } yyvsp -= yylen; yylsp -= yylen; yyssp -= yylen; *++yyvsp = yyval; yylsp++; yyn = yyr1[yyn]; yystate = yypgoto[yyn - 112 ] + *yyssp; if (yystate >= 0 && yystate <= 1184 && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - 112 ]; goto yynewstate; yyerrlab: if (! yyerrstatus) { yyerror("parse error"); } if (yyerrstatus == 3) { if (yychar == 0 ) return(1) ; yychar = -2 ; } yyerrstatus = 3; goto yyerrhandle; yyerrdefault: if (yyssp == yyss) return(1) ; yyvsp--; yylsp--; yystate = *--yyssp; yyerrhandle: yyn = yypact[yystate]; if (yyn == -32768 ) goto yyerrdefault; yyn += 1 ; if (yyn < 0 || yyn > 1184 || yycheck[yyn] != 1 ) goto yyerrdefault; yyn = yytable[yyn]; if (yyn == 454 ) return(0) ; *++yyvsp = yylval; *++yylsp = yylloc; yystate = yyn; goto yynewstate; }