This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

warning feature or bug ?



Hello there,

For the following code

struct S
{
	S();
	~S();
private:
	char * a;
	char * b;
};

S::S()
{
	a = new char;
	b = new char [ 10];
}

S::~S()
{
	delete [] a;	// error here
	delete b;	// error here
}

compiled by egcs-980615 with flags -ansi -pedantic -O -Wall produced no
errors or warnings at all.

While the general case is hard to fix, the simple case of compiling
one translation unit should be easy, and useful.

It would seem to be the case to keep track of which of

1. ordinary new
2. ordinary delete
3. array new
4. array delete

have been called for a particular variable, and produce an error or
warning for a later conflicting case.

Regards


David C Binderman MSc BSc	+44 1293 534847		dcb@pncl.co.uk



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]