bug in two versions of egcs g++

David Blackman david@prometheus.com.au
Mon Sep 28 01:28:00 GMT 1998


This is on a red-hat 5.1 linux (intel achitecture) system. egcs-1.02 as
supplied and egcs-1.1 downloaded from the net.

Both compilers seem fairly stable and useful, but both crashed with an
internal error when given this (seriously wrong) source code. We can live
with this, but thought you might like to know.

The command line to compile was
g++ -Wall -O2 -c buggy.c

Here is the source file. It has a serious syntax error at lines 1 to 3.
The === lines are not part of the source code.
========================================================================
static const int 

class ppbuffer
{
    char *ptr;
    int offset,rowlength,t,b,l,r;

public:

    enum {trans=0, col=1, oldedge=2, newedge=3} ;
    
    ppbuffer(int top, int bottom, int left, int right)
    {
	rowlength=right-left; t=top; b=bottom; l=left; r=right;
	offset=t*rowlength+l;
	int size=(bottom-top)*rowlength;
~	ptr = new char[size];
    }

    ~ppbuffer() {delete[] ptr;}

    char& index(int x, int y)
    {
#ifndef NDEBUG
	if (x<t) abort();
	if (x>=b) abort();
        if (y<l) abort();
	if (y>=r) abort();
#endif
	return ptr[x*rowlength+y-offset];
    }
};

int drawPolyPoly(
    int numPolys,
    const int numPolyPoints[],
    const int points[],
    int id)
{
    const int BIG=0x7fffffff;
    int top= BIG, bottom= -BIG, left=BIG, right= -BIG;

    {
	int i,j;
 	j=0;
	for (i=0; i<numPolys; i++) j+=numPolyPoints[i];
	if (j==0) return(0);
	j+=j;
	for (i=0; i<j; i+=2)
	{
	    int x=points[i]; if (x<top) top=x; if (x>bottom) bottom=x;
	    x=points[i+1]; if (x<left) left=x; if (x>right) right=x;
	}
	top-=4; bottom+=4; left-=4; right+=4;
    }

    ppbuffer ppbuf(top,bottom,left,right);

    return(0);
}
=====================================================================
Version of first compiler:
=====================================================================
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.27/specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
====================================================================
Message from first compiler:
====================================================================
buggy.C:32: Internal compiler error.
buggy.C:32: Please submit a full bug report to `egcs-bugs@cygnus.com'.
====================================================================
Version of second compiler:
====================================================================
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
====================================================================
Message from second compiler:
====================================================================
tree.c:1953: Internal compiler error in function chainon
====================================================================

Thanks for the excellent free compiler, and best of luck bug-hunting.




More information about the Gcc-bugs mailing list