g++ delete issue
Jim Wilson
wilson@specifixinc.com
Thu Apr 8 02:22:00 GMT 2004
Nilmoni Deb wrote:
> My concern is that the compiler allows the explicit "delete &u"
> operation even though the variable u is not user allocated. Should
> the compiler be expected to give a warning/error message when such a
> statement appears ?
In general, you will get better answers if you file bugs into our
bugzilla bug database rather than sending email to gcc-bugs. We don't
track bugs sent via email.
I don't have a copy of the C++ standard, so I can't comment definitively
on this. However, I can note that in general it is not possible for the
compiler to know how an object has been allocated in all cases. The
object might have been allocated in a different function for instance.
There might be multiple assignments to the variable under different
conditions, and it may not be obvious at compile time which one will
reach the delete. In such cases, language standards generally do not
require any warning/error at all, even for relatively simple cases like
this one.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc-bugs
mailing list