This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32984] add checking for array new & delete
- From: "gdr at cs dot tamu dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Aug 2007 13:01:42 -0000
- Subject: [Bug c++/32984] add checking for array new & delete
- References: <bug-32984-9596@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from gdr at cs dot tamu dot edu 2007-08-04 13:01 -------
Subject: Re: New: add checking for array new & delete
"dcb314 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> writes:
| 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.
Special, dedicated tools exist for that task. I would suggest
you use one of them.
The above should not be the business of the *compiler*.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32984