[gnu.gcc.bug] gcc optimization bug

jhh%thyme.Berkeley.EDU@GINGER.BERKELEY.EDU (John H. Hartman) (06/02/89)

There is a bug in Gcc 1.34 when it compiles optimized code for the 68k.
I've enclosed a file that produces the error.  The original file was huge
and I managed to shrink it quite a bit. On line 167 a pointer is incremented.
If you compile using the -O flag the resulting assembly code does not
increment the pointer. 

John

----------------- cut here --------------------------------
typedef int *ClientData;
typedef struct _file {
    unsigned char *lastAccess;	 
    int readCount;		 
    int writeCount;		 
    unsigned char *buffer;	 
    int bufSize;		 
    void (*readProc)();		 
    void (*writeProc)();	 
    int (*closeProc)();		 
    ClientData clientData;	 
    int status;			 
    int flags;			 
    struct _file *nextPtr;	 
} FILE;
extern FILE stdioInFile, stdioOutFile, stdioErrFile;
typedef	unsigned char	u_char;
typedef	unsigned short	u_short;
typedef	unsigned int	u_int;
typedef	unsigned long	u_long;
typedef	unsigned short	ushort;		 
typedef	struct	_physadr { short r[1]; } *physadr;
typedef	struct	label_t	{
	int	val[13];
} label_t;
typedef	struct	_quad { long val[2]; } quad;
typedef	long	daddr_t;
typedef	char *	caddr_t;
typedef	long *	qaddr_t;	 
typedef	u_long	ino_t;
typedef	long	swblk_t;
typedef	int	size_t;
typedef	long	time_t;
typedef	short	dev_t;
typedef	long	off_t;
typedef	u_short	uid_t;
typedef	u_short	gid_t;
typedef long	fd_mask;
typedef	struct fd_set {
	fd_mask	fds_bits[(((256 )+(( (sizeof(fd_mask) * 8		)	)-1))/( (sizeof(fd_mask) * 8		)	)) ];
} fd_set;
struct	stat
{
	dev_t	st_dev;
	ino_t	st_ino;
	unsigned short st_mode;
	short	st_nlink;
	uid_t	st_uid;
	gid_t	st_gid;
	dev_t	st_rdev;
	off_t	st_size;
	time_t	st_atime;
	int	st_spare1;
	time_t	st_mtime;
	int	st_spare2;
	time_t	st_ctime;
	int	st_spare3;
	long	st_blksize;
	long	st_blocks;
	long	st_serverID;
	long	st_version;
	long	st_userType;
	long	st_devServerID;
};
extern char _ctype_bits[];
extern int	errno;		 
extern int	sys_nerr;	 
extern char	*sys_errlist[];	 
typedef int		NG_NUM;		 
typedef long		ART_NUM;	 
    typedef long	ART_UNREAD;
typedef long		ART_POS;	 
typedef int		ART_LINE;	 
typedef short		ACT_POS;	 
typedef unsigned int	MEM_SIZE;	 
  struct stat filestat;
char	*index();
char	*rindex();
char	*getenv();
char	*strcat();
char	*strcpy();
char	*sprintf();
  char buf[1024	+1];	 
  char cmd_buf[512	];	 
  char *indstr = ">" ;	 
  char *cwd = ((char *)0)   ;		 
  char *dfltcmd = ((char *)0)   ;	 
      int debug = 0 ;				 
      int scanon = 0 ;				 
  char  mbox_always = (0)  ;			 
  char  norm_always = (0)  ;			 
  char  checkflag = (0)  ;			 
  char  suppress_cn = (0)  ;			 
  int countdown = 5 ;	 
  char  muck_up_clear = (0)  ;			 
  char  erase_screen = (0)  ;			 
  char  can_home_clear = (0)  ;		 
  char  findlast = (0)  ;			 
  char  typeahead = (0)  ;			 
	  char  verbose = (1)  ;			 
      char  verify = (0)  ;			 
  int marking = 0  ;			 
  ART_LINE initlines = 0 ;		 
long atol(), fseek(), ftell();
  char  in_ng = (0)  ;		 
  char mode = 'i' ;		 
  FILE *tmpfp = ((FILE *)0)   ;	 
  NG_NUM nextrcline = 0 ;	 
extern errno;
  char nullstr[] = "" ;
  char sh[] = "/bin/sh"  ;
  char defeditor[] = "/sprite/cmds/vi"  ;
  char hforhelp[] = "Type h for help.\n" ;
  char readerr[] = "rn read error" ;
  char unsubto[] = "\n\nUnsubscribed to newsgroup %s\n" ;
  char cantopen[] = "Can't open %s\n" ;
  char cantcreate[] = "Can't create %s\n" ;
      char nocd[] = "Can't chdir to directory %s\n" ;
char *
dointerp(dest,destsize,pattern,stoppers)
register char *dest;
register int destsize;
register char *pattern;
char *stoppers;
{
    char *ngs_buf = 0 ;
    char *path_buf = 0 ;
    char *follow_buf = 0 ;
    register char *s, *h;
    register int i;
    char scrbuf[512];
    int metabit = 0;
    while (*pattern && (!stoppers || !index(stoppers,*pattern))) {
	if (debug & 8)
	    printf("dointerp till %s at %s\n",stoppers?stoppers:"",pattern);
	if (*pattern == '%' && pattern[1]) {
	    for (s=0 ; !s; ) {
		switch (*++pattern) {
		case 'F':
			{
			int off;
			s = ngs_buf = fetchlines();
			if (h = instr(s,"net.general")) {
			    off = h-s;
			    strncpy(scrbuf,s,off+4);
			    strcpy(scrbuf+off+4,"followup");
			    safecpy(scrbuf+off+12,h+11,sizeof(scrbuf));
			    s = scrbuf;
			}
		    }
		    break;
		case 'T':
		    if (*pattern == 'T') {
			    s = path_buf = fetchlines();
			i = strlen();
			if ((!strncmp(s,s,i))  && s[i] == '!')
			    s += i + 1;
		    }
		    break;
		}
	    }
	    if (s == dest) {
		while (*dest) {
		    if (--destsize <= 0)
			abort_interp();
		    *dest |= i;
		    dest++;
		}
	    }
	}
    }
getout:
    exit();
}