This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32984] New: add checking for array new & delete
- From: "dcb314 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Aug 2007 12:21:18 -0000
- Subject: [Bug c++/32984] New: add checking for array new & delete
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Given the following C++ code
class K
{
public:
void f();
void g();
private:
int * a;
double * b;
float * c;
unsigned int * d;
};
void K :: f()
{
a = new int;
b = new double [ 10];
delete c;
delete [] d;
}
void K :: g()
{
delete [] a; // error
delete b; // error
c = new float [ 20]; // error
d = new unsigned int; // error
}
Recent snapshot g++ 4.3 20070803 can't find anything
wrong with the code.
Suggest enhance compiler to track use of plain new/delete
and array new/delete and warn where possible to detect
an error.
Manual memory allocation and de-allocation is enough
of a pain in C++ without total silence from the compiler.
--
Summary: add checking for array new & delete
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dcb314 at hotmail dot com
GCC host triplet: x86_64-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32984