Path: utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!MOOSE.CITA.UTORONTO.CA!trq From: trq@MOOSE.CITA.UTORONTO.CA (Tom Quinn) Newsgroups: gnu.gcc.bug Subject: bug in m68k gcc 1.32 Message-ID: <8901162313.AA10017@moose.cita.utoronto.ca> Date: 16 Jan 89 23:13:23 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 114 gcc with the "-O -fomit-frame-pointer" flags compiles the following code into something which loses track of the stack pointer, and therefore, returns to never-neverland. This is gcc version 1.32 on a Sun 3/50 running SunOS 3.5. Tom Quinn Canadian Institute for Theoretical Astrophysics 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 -S -g -v -O -fomit-frame-pointer -c history.c gcc version 1.32 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000_ _ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 history.c /tmp/cca28687.cpp GNU CPP version 1.32 /usr/local/lib/gcc-cc1 /tmp/cca28687.cpp -quiet -dumpbase history.c -fomit-frame-pointer -g -O -version -o history.s GNU C version 1.32 (68k, MIT syntax) compiled by GNU C version 1.32. The offending assembler: .stabd 68,0,31 clrl sp@- movel a2,sp@- jbsr _edit_line movel d0,d1 moveq #14,d3 cmpl d1,d3 jeq L15 jlt L25 moveq #13,d3 cmpl d1,d3 jeq L6 addqw #8,sp ### this should be before the above jumps. jra L21 L25: moveq #16,d3 cmpl d1,d3 jeq L17 jra L21 The code: ------------------------------------------------------------------------ extern struct _iobuf { int _cnt; unsigned char *_ptr; unsigned char *_base; int _bufsiz; short _flag; char _file; } _iob[]; extern char _ctype_[]; typedef struct { char line[82 ]; int num; } HISTORY; static char search_str[40] = ""; static HISTORY **hist; extern int interrupt; static int hindex, hlev, hsize; char * edit_hist() { char *current, *strcpy(), *strncpy(); int i, index = 0; current = hist[hindex%hsize]->line; erase_str(current,82 ); for(;;) { switch(i = edit_line(current,(char **)0 )) { case 13 : interrupt = 0; search_str[0] = '\0'; printf("\n"); for(i = strlen(current) - 1;i >= 0 && current[i] != '\0';i--) { if(!((_ctype_+1)[current[i]]&010 ) ) break; current[i] = '\0'; } if(i < 0) { break; } if(hindex == 0 || strcmp(hist[hindex%hsize]->line, hist[(hindex - 1)%hsize]->line) != 0) { hist[hindex++%hsize]->num = hlev++; } return(current); case 14 : if(index > 0) { index--; } erase_str(current,82 ); (void)strcpy(current,hist[(hsize + hindex - index)%hsize]->line); break; case 16 : if(index <= hsize - 1 && (index == 0 || hist[(hsize + hindex - index)%hsize]->num > 0)) { index++; } erase_str(current,82 ); if(hist[(hsize + hindex - index)%hsize]->num > 0) { (void)strcpy(current,hist[(hsize + hindex - index)%hsize]->line); } break; default: (--((&_iob[1]) )->_cnt>=0? (int)(*((&_iob[1]) )->_ptr++=(unsigned char)((7 ))):_flsbuf((unsigned char)((7 )),(&_iob[1]) )) ; break; } (void)fflush((&_iob[1]) ); } }