[gnu.g++.bug] This code crashes g++

sorensen@IMAGER.MIT.EDU (Greg Sorensen) (06/18/89)

Howdy.  The piece of code below crashes g++ 1.35.0.
I'm running on a Sun4, OS4.0.
It takes about three minutes for the file system to fill up and 
the fatal signal to reach g++.

The last line of the program, if commented out, prevents the
crash.  This points to memcpy as the culprit.

-greg

Here's a typescript:

Script started on Sat Jun 17 00:54:57 1989
imager.mit.edu:~/code/++/test > ls -l
total 5
-rw-r--r--  1 sorensen       39 Jun 17 00:53 checkbomb.C
-rw-r--r--  1 sorensen     1318 Jun 17 00:53 checkbomb.h
-rw-r--r--  1 sorensen        0 Jun 17 00:54 typescript
imager.mit.edu:~/code/++/test > g++ -v
g++ version 1.35.0
imager.mit.edu:~/code/++/test > g++ checkbomb.C

/home: write failed, file system is full
g++: Program cc1plus got fatal signal 4.
imager.mit.edu:~/code/++/test > ls -l
total 19635
-rw-r--r--  1 sorensen       39 Jun 17 00:53 checkbomb.C
-rw-r--r--  1 sorensen     1318 Jun 17 00:53 checkbomb.h
-rw-r--r--  1 sorensen 295649280 Jun 17 00:59 core
-rw-r--r--  1 sorensen        0 Jun 17 00:54 typescript
imager.mit.edu:~/code/++/test > more check*
::::::::::::::
checkbomb.C
::::::::::::::
#include "checkbomb.h"

main()
{
	;
}

(Next file: checkbomb.h)
::::::::::::::
checkbomb.h
::::::::::::::
/*
	checkbomb.h: sample container classes
*/

#include <stream.h>

class img {
friend class int_image;
private:
	int foo;
public:
	img() {;}
	~img() { cout << "lowest-level base destructor\n"; }
};

class int_image: public img {
friend class int1D;
friend class int2D;
private:
	int * int_base = 0;
	int int_length = 0;
public:
	int_image(){;}
	int_image(int * start, int length);
};

int_image::int_image(int * start, int length) 
{
  	int_base = start;
  	int_length = length;
}


class int1D: public int_image 
{
friend class int2D;
private:
	int x_dim =0;
public:
	int1D(){;}
	int1D(int * start, int xlength);
};

int1D::int1D(int * start,int xlength) : (start, xlength)
{
	x_dim = xlength;
}

class int2D : public int_image
{
private:
	int x_dim;
	int y_dim;
	int1D * int1D_list;
	int1D * cur_1D;
public:
	int2D(int * start, int xlength, int ylength);
};

int2D::int2D(int * start, int xlength, int ylength): (start,(xlength * ylength)){
	x_dim = xlength;
	y_dim = ylength;
	int1D int1Dstuff[y_dim];
	/*
	...stuff done to int1Dstuff...
	*/
	// since int1Dstuff will be deallocated, copy this stuff to a safe place...
	char * temp_int = calloc(y_dim, sizeof(int1D));

	//this line causes the compiler to dump core.
	int1D_list =
		(int1D *) memcpy(temp_int, (char *)int1Dstuff, y_dim * sizeof(int1D) );
}

imager.mit.edu:~/code/++/test > rm core
imager.mit.edu:~/code/++/test > exit
imager.mit.edu:~/code/++/test > 
script done on Sat Jun 17 01:00:29 1989