🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1912

bug in m68k gcc 1.30

#1912
From: Tom Quinn
Date: Sun, 06 Nov 1988 22:25
149 lines
7242 bytes
The following code causes gcc to get a fatal signal when compiled with
the -O option.  This is gcc v1.30 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 -g -v -O -c mifpolycon.c
gcc version 1.30
 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 mifpolycon.c /tmp/cca08664.cpp
GNU CPP version 1.30
 /usr/local/lib/gcc-cc1 /tmp/cca08664.cpp -quiet -dumpbase mifpolycon.c -g -O -version -o /tmp/cca08664.s
GNU C version 1.30 (68k, MIT syntax) compiled by GNU C version 1.30.
gcc: Program cc1 got fatal signal 6.

The code:
------------------------------------------------------------------------
typedef struct _GC    *GCPtr;
char *alloca();
typedef struct _DDXPoint *DDXPointPtr;
typedef struct _DDXPoint {
    short x, y;
} DDXPointRec;
typedef struct _DrawInfo *DrawablePtr;	
typedef struct _GC{
    int		miTranslate:1;		 
    void (* FillSpans)();
} GC;
typedef struct _Window *WindowPtr;
typedef struct _DrawInfo {
    short	type;
} DrawableRec;
typedef struct _Window {
	DDXPointRec  absCorner;
} WindowRec;
typedef struct _SppPoint {
	double	x, y;
} SppPointRec, *SppPointPtr;
static int GetFPolyYBounds();
void
miFillSppPoly(dst, pgc, count, ptsIn, xTrans, yTrans, xFtrans, yFtrans)
    DrawablePtr 	dst;
    GCPtr		pgc;
    int			count;           
    SppPointPtr 	ptsIn;   
    int			xTrans, yTrans;
    double		xFtrans, yFtrans;
{
    double		xl, xr, ml, mr, dy, i;
    int			y, j, imin, ymin, ymax, *width, *FirstWidth, *Marked; 
    register int	left, right, nextleft, nextright;
    DDXPointPtr 	ptsOut,
    			FirstPoint;	 
    if (pgc->miTranslate && (dst->type == 0 ) )
    {
	xTrans += ((WindowPtr)dst)->absCorner.x;
	yTrans += ((WindowPtr)dst)->absCorner.y;
    }
    imin = GetFPolyYBounds(ptsIn, count, yFtrans, &ymin, &ymax);
    y = ymax - ymin + 1;
    ptsOut = FirstPoint = (DDXPointPtr)alloca((int)(sizeof(DDXPointRec) * y)) ;
    width = FirstWidth = (int *) alloca((int)(sizeof(int) * y)) ;
    Marked = (int *) alloca((int)(sizeof(int) * count)) ;
    if(!ptsOut || !width || !Marked || (count < 3) || (y <= 0))
    {
	 ;
	 ;
	 ;
	return;
    }
    for(j = 0; j < count; j++)
	Marked[j] = 0;
    nextleft = nextright = imin;
    Marked[imin] = -1;
    y = (int) ({ double __value, __arg = (ptsIn[nextleft].y + yFtrans); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) ;
    do
    {
        if ((y > (ptsIn[nextleft].y + yFtrans) ||
 	     ((((y) - ( ptsIn[nextleft].y + yFtrans)) > 0.0 ? ((y) - ( ptsIn[nextleft].y + yFtrans)) : -((y) - ( ptsIn[nextleft].y + yFtrans)))	 <= 0.000001 ) ) &&
	     Marked[nextleft] != 1)
	{
	    Marked[nextleft]++;
            left = nextleft++;
            if (nextleft >= count)
                nextleft = 0;
	    dy = ptsIn[nextleft].y - ptsIn[left].y;
	    if (dy != 0.0)
	    { 
		ml = (ptsIn[nextleft].x - ptsIn[left].x) / dy;
		dy = y - (ptsIn[left].y + yFtrans);
		xl = (ptsIn[left].x + xFtrans) + ml * (((dy) > ( 0)) ? (dy) : ( 0)) ; 
	    }
        }
        if ((y > ptsIn[nextright].y + yFtrans) ||
 	     ((((y) - ( ptsIn[nextright].y + yFtrans)) > 0.0 ? ((y) - ( ptsIn[nextright].y + yFtrans)) : -((y) - ( ptsIn[nextright].y + yFtrans)))	 <= 0.000001 ) 
	     && Marked[nextright] != 1)
	{
	    Marked[nextright]++;
            right = nextright--;
            if (nextright < 0)
                nextright = count - 1;
	    dy = ptsIn[nextright].y - ptsIn[right].y;
	    if (dy != 0.0) 
	    { 
		mr = (ptsIn[nextright].x - ptsIn[right].x) / dy;
		dy = y - (ptsIn[right].y + yFtrans); 
		xr = (ptsIn[right].x + xFtrans) + mr * (((dy) > ( 0)) ? (dy) : ( 0)) ;
	    }
        }
        i = ((((ptsIn[nextleft].y) < ( ptsIn[nextright].y)) ? (ptsIn[nextleft].y) : ( ptsIn[nextright].y))  + yFtrans) - y;
	if (i < 0.000001 )
	{
	    if(Marked[nextleft] && Marked[nextright])
	    {
	        break;
	    }
	    continue;
	}
	else
	{
		j = (int) i;
		if(!j)
		    j++;
	}
        while (j > 0) 
        {
            ptsOut->y = (y) + yTrans;
            if (xl < xr) 
            {
                *(width++) = ({ double __value, __arg = (xr); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; })  - ({ double __value, __arg = (xl); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) ;
                (ptsOut++)->x = ({ double __value, __arg = (xl); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; })  + xTrans;
            }
            else 
            {
                *(width++) = ({ double __value, __arg = (xl); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; })  - ({ double __value, __arg = (xr); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) ;
                (ptsOut++)->x = ({ double __value, __arg = (xr); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; })  + xTrans;
            }
            y++;
	    xl += ml;
	    xr += mr;
	    j--;
        }
    }  while (y <= ymax);
    (*pgc->FillSpans)(dst, pgc, 
		      ptsOut-FirstPoint, FirstPoint, FirstWidth, 1);
}
Technical Details
Message-ID: <8811062225.AA12988@moose.cita.utoronto.ca>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!osu-cis!tut.cis.ohio-state.edu!moose.cita.utoronto.ca!trq

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!osu-cis!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.30
Message-ID: <8811062225.AA12988@moose.cita.utoronto.ca>
Date: 6 Nov 88 22:25:49 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 148