This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
warning feature or bug ?
- To: egcs-bugs at cygnus dot com
- Subject: warning feature or bug ?
- From: David C Binderman <dcb at pncl dot co dot uk>
- Date: Thu, 2 Jul 1998 20:24:52 +0100 (BST)
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