🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1790

bug in m68k gcc 1.29

#1790
From: Tom Quinn
Date: Thu, 13 Oct 1988 13:22
139 lines
3865 bytes
The following code causes gcc to get a fatal signal when compiled with
the "-O" option.  This is gcc version 1.29 with the second fix posted
by RMS 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 comile:
gcc -g -v -O -c midash.c
gcc version 1.29
 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 midash.c /tmp/cca00683.cpp
GNU CPP version 1.29
 /usr/local/lib/gcc-cc1 /tmp/cca00683.cpp -quiet -dumpbase midash.c -g -O -version -o /tmp/cca00683.s
GNU C version 1.29 (68k, MIT syntax) compiled by GNU C version 1.29.
gcc: Program cc1 got fatal signal 11.

The code:
------------------------------------------------------------------------
typedef struct _DDXPoint *DDXPointPtr;
typedef struct _DDXPoint {
    short x, y;
} DDXPointRec;
typedef struct _miDash *miDashPtr;
extern miDashPtr   miDashLine();
typedef struct _miDash {
    DDXPointRec	pt;
    int		e1, e2;	 
    int		e;	 
    int		which;
    int		newLine; 
    } miDashRec;
static miDashPtr CheckDashStorage();
miDashPtr
miDashLine(npt, ppt, nDash, pDash, offset, pnseg)
int npt;
DDXPointPtr ppt;
int nDash;
unsigned char *pDash;
int offset;
int *pnseg;
{
    DDXPointRec pt1, pt2;
    int lenCur;		 
    int lenMax;		 
    int iDash = 0;	 
    int which;		 
    miDashPtr pseg;	 
    miDashPtr psegBase;	 
    int nseg = 0;	 
    int nsegMax = 0;	 
    int x, y, len;
    int adx, ady, signdx, signdy;
    int du, dv, e1, e2, e;
    lenCur = offset;
    which = 0 ;
    while(lenCur > pDash[iDash]) {
	lenCur -= pDash[iDash];
	iDash++;
	if (iDash >= nDash) iDash = 0;
	which = ~which;
    }
    lenMax = pDash[iDash];
    psegBase = (miDashPtr)           0 ;
    while(--npt) {
	pt1 = *ppt++;
	pt2 = *ppt;
	adx = pt2.x - pt1.x;
	ady = pt2.y - pt1.y;
	signdx = ((adx) < 0 ? -1 : ((adx) > 0 ? 1 : 0)) ;
	signdy = ((ady) < 0 ? -1 : ((ady) > 0 ? 1 : 0)) ;
	adx = ((adx) > 0 ? (adx) : -(adx)) ;
	ady = ((ady) > 0 ? (ady) : -(ady)) ;
	if (adx > ady) {
	    du = adx;
	    dv = ady;
	    len = adx;
	} else {
	    du = ady;
	    dv = adx;
	    len = ady;
	}
	e1 = dv * 2;
	e2 = e1 - 2*du;
	e = e1 - du;
	x = pt1.x;
	y = pt1.y;
	nseg++;
	pseg = CheckDashStorage(&psegBase, nseg, &nsegMax);
	pseg->pt = pt1;
	pseg->e1 = e1;
	pseg->e2 = e2;
	pseg->e = e;
	pseg->which = which;
	pseg->newLine = 1;
	while (len--) {
	    if (adx > ady) {
		if (((signdx > 0) && (e < 0)) || ((signdx <=0) && (e <=0))) {
		    e += e1;
		} else {
		    y += signdy;
		    e += e2;
		}
		x += signdx;
	    } else {
		if (((signdx > 0) && (e < 0)) || ((signdx <=0) && (e <=0))) {
		    e +=e1;
		} else {
		    x += signdx;
		    e += e2;
		}
		y += signdy;
	    }
	    lenCur++;
	    if (lenCur >= lenMax) {
		nseg++;
		pseg = CheckDashStorage(&psegBase, nseg, &nsegMax);
		pseg->pt.x = x;
		pseg->pt.y = y;
		pseg->e1 = e1;
		pseg->e2 = e2;
		pseg->e = e;
		which = ~which;
		pseg->which = which;
		pseg->newLine = 0;
		iDash++;
		if (iDash >= nDash) iDash = 0;
		lenMax = pDash[iDash];
		lenCur = 0;
	    }
	}  
    }  
    *pnseg = nseg;
    pseg = CheckDashStorage(&psegBase, nseg+1, &nsegMax);
    pseg->pt = pt2;
    return psegBase;
} 
Technical Details
Message-ID: <8810131322.AA01551@moose.cita.utoronto.ca>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!moose.cita.utoronto.ca!trq

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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.29
Message-ID: <8810131322.AA01551@moose.cita.utoronto.ca>
Date: 13 Oct 88 13:22:19 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 139