Path: utzoo!telly!ddsw1!spl1!philabs!ttidca!psivax!csun!sm.unisys.com!cs.utexas.edu!tut.cis.ohio-state.edu!moose.cita.toronto.edu!trq From: trq@moose.cita.toronto.edu (Tom Quinn) Newsgroups: gnu.gcc.bug Subject: bug in m68k gcc 1.29 Message-ID: <8810102049.AA13844@moose.cita.toronto.edu> Date: 10 Oct 88 20:49:50 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 145 The following code causes gcc to get a fatal signal. This is gcc version 1.29 on a Sun 3/50 running SunOS 3.5. Tom Quinn Canadian Institute for Theoretical Astrophysics trq@moose.cita.toronto.edu SOON TO BE 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 colormap.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 colormap.c /tmp/cca22036.cpp GNU CPP version 1.29 /usr/local/lib/gcc-cc1 /tmp/cca22036.cpp -quiet -dumpbase colormap.c -g -O -version -o /tmp/cca22036.s GNU C version 1.29 (68k, MIT syntax) compiled by GNU C version 1.29. gcc: Program cc1 got fatal signal 6. The code: ------------------------------------------------------------------------ typedef unsigned char *pointer; typedef int Bool; char *alloca(); unsigned long *Xrealloc(); typedef unsigned long Pixel; typedef struct _ColormapRec *ColormapPtr; typedef struct _Visual *VisualPtr; typedef struct _CMEntry { short refcnt; } Entry; typedef struct _ColormapRec { VisualPtr pVisual; int freeRed; int freeGreen; int freeBlue; int *numPixelsRed; int *numPixelsGreen; int *numPixelsBlue; Pixel **clientPixelsRed; Pixel **clientPixelsGreen; Pixel **clientPixelsBlue; Entry *red; Entry *green; Entry *blue; } ColormapRec; typedef struct _Visual { int offsetRed, offsetGreen, offsetBlue; } VisualRec; static int AllocDirect (client, pmap, c, r, g, b, contig, pixels, prmask, pgmask, pbmask) int client; ColormapPtr pmap; int c, r, g, b; Bool contig; Pixel *pixels; Pixel *prmask, *pgmask, *pbmask; { Pixel *ppixRed, *ppixGreen, *ppixBlue; Pixel *ppix, *pDst, *p; int npix; Bool okR, okG, okB; for(p = pixels; p < pixels + c; p++) *p = 0; ppixRed = (Pixel *)alloca((int)((c << r) * sizeof(Pixel))) ; ppixGreen = (Pixel *)alloca((int)((c << g) * sizeof(Pixel))) ; ppixBlue = (Pixel *)alloca((int)((c << b) * sizeof(Pixel))) ; if (!ppixRed || !ppixGreen || !ppixBlue) { if (ppixBlue) ; if (ppixGreen) ; if (ppixRed) ; return( 11 ); } okR = AllocCP(pmap, pmap->red, c, pmap->freeRed, r, contig, ppixRed, prmask); okG = AllocCP(pmap, pmap->green, c, pmap->freeGreen, g, contig, ppixGreen, pgmask); okB = AllocCP(pmap, pmap->blue, c, pmap->freeBlue, b, contig, ppixBlue, pbmask); if (!okR || !okG || !okB) { if (okR) for(ppix = ppixRed, npix = (c << r); --npix >= 0; ppix++) pmap->red[*ppix].refcnt = 0; if (okG) for(ppix = ppixGreen, npix = (c << g); --npix >= 0; ppix++) pmap->green[*ppix].refcnt = 0; if (okB) for(ppix = ppixBlue, npix = (c << b); --npix >= 0; ppix++) pmap->blue[*ppix].refcnt = 0; ; ; ; return( 11 ); } *prmask <<= pmap->pVisual->offsetRed; *pgmask <<= pmap->pVisual->offsetGreen; *pbmask <<= pmap->pVisual->offsetBlue; npix = c << r; ppix = (Pixel *) Xrealloc((pointer)((pmap->clientPixelsRed)[client]), (unsigned long)( ((pmap->numPixelsRed)[client] + npix) * sizeof(Pixel))) ; (pmap->clientPixelsRed)[client] = ppix; ppix += (pmap->numPixelsRed)[client]; for (pDst = pixels, p = ppixRed; p < ppixRed + npix; p++) { *ppix++ = *p; if(p < ppixRed + c) *pDst++ |= *p << pmap->pVisual->offsetRed; } (pmap->numPixelsRed)[client] += npix; pmap->freeRed -= npix; npix = c << g; ppix = (Pixel *) Xrealloc((pointer)((pmap->clientPixelsGreen)[client]), (unsigned long)( ((pmap->numPixelsGreen)[client] + npix) * sizeof(Pixel))) ; (pmap->clientPixelsGreen)[client] = ppix; ppix += (pmap->numPixelsGreen)[client]; for (pDst = pixels, p = ppixGreen; p < ppixGreen + npix; p++) { *ppix++ = *p; if(p < ppixGreen + c) *pDst++ |= *p << pmap->pVisual->offsetGreen; } (pmap->numPixelsGreen)[client] += npix; pmap->freeGreen -= npix; npix = c << b; ppix = (Pixel *) Xrealloc((pointer)((pmap->clientPixelsBlue)[client]), (unsigned long)( ((pmap->numPixelsBlue)[client] + npix) * sizeof(Pixel))) ; (pmap->clientPixelsBlue)[client] = ppix; ppix += (pmap->numPixelsBlue)[client]; for (pDst = pixels, p = ppixBlue; p < ppixBlue + npix; p++) { *ppix++ = *p; if(p < ppixBlue + c) *pDst++ |= *p << pmap->pVisual->offsetBlue; } (pmap->numPixelsBlue)[client] += npix; pmap->freeBlue -= npix; ; ; ; return ( 0 ); }