This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36633] [4.4 regression] warning "array subscript is below array bounds" on delete [] with -O2, -Wall
- From: "mark at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jul 2008 03:42:20 -0000
- Subject: [Bug c++/36633] [4.4 regression] warning "array subscript is below array bounds" on delete [] with -O2, -Wall
- References: <bug-36633-14909@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from mark at codesourcery dot com 2008-07-10 03:42 -------
Subject: Re: [4.4 regression] warning "array subscript is
below array bounds" on delete [] with -O2, -Wall
paolo dot carlini at oracle dot com wrote:
> Mark, could you possibly comment on this PR? With some good hints I could even
> try to work on it...
I don't see that the C++ front-end is doing anything obviously wrong
here. The cast to (long unsigned int *) is coming from the presence of
the array "cookie". When we allocate an array, we allocate a few extra
bytes and scribble the length of the array into that extra space. Then,
when the user does "delete[]" we know how many array elements there are,
so we can run all the destructors. See:
http://www.codesourcery.com/public/cxx-abi/abi.html#array-cookies
Thanks,
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36633