J
James Kanze
What bugs will hide:
delete a;
a = NULL;
From what it will hide these? Sounds surprizing. It exposes
bugs and does not hide. You should explain how this rule is
harmful.
It creates the impression that it exposes bugs, but it doesn't.
(I don't think it hides any, however. It just gives a false
sense of security.)
The one case such a rule might make sense is if you're using
garbage collection, since a garbage collector won't collect the
memory if there is a valid pointer to it (even if the destructor
has run). Most of the time, even there, however, there's no
point in it, since the pointer will either be reused, or go out
of scope.
The only time this rule makes any sense at all is if the pointer
will be reused, but not immediately, and you have to check to
determine whether it is already in use before reusing it. (The
classical example is a cached computed value. If you do
anything which might change the value, you delete and null the
pointer, and if you need the value, you check for null before
recalculating it.)