[gnu.gcc.bug] 1.29 core dump in cc1

hrp%snoid.CRAY.COM@UC.MSC.UMN.EDU (Hal Peterson) (10/14/88)

(this may be the same as a problem I reported earlier this week; the
symptoms are the same and the backtrace looks the same.  The example
code is considerably smaller, so that should be a win.)

GCC version 1.29

(input file attached; it's some code from the X11R3 server.)

command line:  "gcc -c -O -msoft-float crash.c"

configuration:  md -> m68k.md
		tm.h -> tm-sun3.h

running on a Sun-3/280 and on a Sun-3/50, both running SunOS 3.5.

CC1 dies with a fatal signal 11 and dumps core.

--
Hal Peterson / Cray Research / 1440 Northland Dr. / Mendota Hts, MN  55120
hrp%hall.cray.com@uc.msc.umn.edu	bungia!cray!hrp	    (612) 681-3145
============================================================
extern unsigned long globalSerialNumber;
typedef long ptrdiff_t;
typedef unsigned long size_t;
typedef unsigned char *pointer;
typedef int Bool;
typedef unsigned long PIXEL;
typedef unsigned long ATOM;
typedef pointer	FID;
typedef struct _FontPathRec *FontPathPtr;
typedef struct _NewClientRec *NewClientPtr;
char *alloca();
char		*ReadRequestFromClient();
char		*strcat();
char		*strncat();
char		*strcpy();
char		*strncpy();
Bool		CloseDownConnection();
FontPathPtr	GetFontPath();
FontPathPtr	ExpandFontNamePattern();
FID		FiOpenForRead();
void		CreateWellKnownSockets();
void		SetDefaultFontPath();
void		FreeFontRecord();
void		SetFontPath();
void		ErrorF();
void		Error();
void		FatalError();
void		ProcessCommandLine();
void		Xfree();
void		FlushAllOutput();
void		FlushIfCriticalOutputPending();
unsigned long	*Xalloc();
unsigned long	*Xrealloc();
long		GetTimeInMillis();
typedef struct _DDXPoint *DDXPointPtr;
typedef struct _Box *BoxPtr;
extern unsigned long globalSerialNumber;
typedef struct _DDXPoint {
    short x, y;
} DDXPointRec;
typedef struct _Box {
    short x1, y1, x2, y2;
} BoxRec;
typedef struct _Region *RegionPtr;
extern int SingleRectRegionEqual();
typedef struct _miDash *miDashPtr;
extern void  miPutImage();
extern void  miGetImage();
extern RegionPtr  miCopyArea();
extern RegionPtr  miCopyPlane();
extern void  miClearToBackground();
extern int   miValidateTree();
extern void  miPolySegment();
extern void  miPolyRectangle();
extern void  miFillPolygon();
extern int   miPolyText8();
extern int   miPolyText16();
extern void  miImageText8();
extern void  miImageText16();
extern int   miFillConvexPoly();
extern int   miFillGeneralPoly();
extern void miNotMiter();
extern void miMiter();
extern void miWideLine();
extern void miWideDash();
extern void  miPolyArc();
extern void miPolyFillRect();
extern void miPolyFillArc();
extern void  miPolyGlyphBlt();
extern void  miImageGlyphBlt();
extern void  miZeroLine();
extern void  miPaintWindow();
extern miDashPtr   miDashLine();
extern void  miPushPixels();
extern void  miGetPts(), miRoundCap(), miOneSegWide();
extern int   miPtToAngle();
extern    RegionPtr miRegionCreate();
extern    void miRegionCopy();
extern    void miRegionDestroy();
extern    int miIntersect();
extern    int miInverse();
extern    int miUnion();
extern    int miSubtract();
extern    void miRegionReset();
extern    void miTranslateRegion();
extern    int miRectIn();
extern	RegionPtr miRectsToRegion();
extern    Bool miPointInRegion();
extern    Bool miRegionNotEmpty();
extern    void miRegionEmpty();
extern    int miNumberRectsInRegion();
extern    void miWindowExposures();    
extern    BoxPtr miRegionExtents();
extern    void miSendGraphicsExpose();
extern    RegionPtr miHandleExposures();
typedef struct _miDash {
    DDXPointRec	pt;
    int		e1, e2;	 
    int		e;	 
    int		which;
    int		newLine; 
    } miDashRec;
typedef struct _SppPoint {
	double	x, y;
} SppPointRec, *SppPointPtr;
extern SppPointRec miExtendSegment();
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, base_e = 0;
    lenCur = offset;
    which = 0 ;
    while(lenCur > pDash[iDash])
    {
	lenCur -= pDash[iDash];
	iDash++;
	if (iDash >= nDash)
	    iDash = 0;
	which = ~which;
    }
    lenMax = pDash[iDash];
    psegBase = (miDashPtr)((void *)0) ;
    pt2 = ppt[0];		 
    while(--npt)
    {
	if ((((ppt[0]).x == ( ppt[1]).x) && ((ppt[0]).y == ( ppt[1]).y)) )
	    continue;		 
	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;
	base_e = 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 && (len || npt <= 1))
	    {
		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;
	    }
	}  
    }  
    if (lenCur == 0 && nseg != 0)
    {
	nseg--;
	which = ~which;
    }
    *pnseg = nseg;
    pseg = CheckDashStorage(&psegBase, nseg+1, &nsegMax);
    pseg->pt = pt2;
    pseg->e = base_e;
    pseg->which = which;
    pseg->newLine = 0;
    return psegBase;
} 
static
miDashPtr
CheckDashStorage(ppseg, nseg, pnsegMax)
miDashPtr *ppseg;		 
int nseg;			 
int *pnsegMax;			 
{
    if (nseg > *pnsegMax)
    {
	*pnsegMax += 16 ;
	*ppseg = (miDashPtr)Xrealloc(*ppseg, 
				     (*pnsegMax)*sizeof(miDashRec));
    }
    return(*ppseg+(nseg-1));
}