warning feature or bug ?
David C Binderman
dcb@pncl.co.uk
Thu Jul 2 12:20:00 GMT 1998
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
More information about the Gcc-bugs
mailing list