Bug(?) int delete operator (egcs 1.1b)

Piotr Gackiewicz gacek@ds14.agh.edu.pl
Wed Nov 11 04:46:00 GMT 1998


Hi.

$ egcs -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)


I found strange behaviour of 'delete' operator.
Try compiling andr running this bit of code:

----- test.C -----

class m {
public:
	m(){};
	~m(){};
};

void fun(m **c)
{
	*c = new m[4];	/*Wird thing - if you create less than 4 objects, it
			works!*/
	return;
}

int main()
{
	m *b;
	fun(&b);
	
	delete b;	/* If changed to 'delete[]' it works also */
	
	return 0;
}
----- End of file -----



Comments:
I KNOW, the standard says: use 'delete[]' for tables. But IMHO, such
statement shouldn't give SIGSEGV error. 

Piotr Gackiewicz.




More information about the Gcc-bugs mailing list