[cfe-dev] Dead stores of NULLs
kremenek at apple.com
Fri Jun 20 15:09:08 PDT 2008
On Jun 19, 2008, at 5:40 PM, Nikita Zhuk wrote:
> First I would like to express my appreciation for the great static
> analyzer, which is already producing useful results. I've been able to
> find several memory leaks and some dead stores.
That's wonderful to hear!
> However, I would like
> to address an issue which produces some dead store reports which are
> technically correct (they really are dead stores), but I would still
> like to ignore them.
> When I allocate an object (by using alloc & init* or one of the
> *Create* functions) and store it into a local variable inside some
> scope, I tend to set it to nil/NULL after the object has been
> released. This is an intentional dead store, which prevents any use of
> that released object later in the same scope.
I agree, the dead store checker is meant to find bugs, not penalize
defensive programming. The following patch causes dead assignments of
null to pointers to not be treated as warnings:
checker-42 (on the clang website) includes this patch. If you find
cases where this fix doesn't handle all cases, please let me know.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev