On Wed, Jul 7, 2010 at 2:33 PM, Matt Neuburg <m...@tidbits.com> wrote: > On or about 7/7/10 11:17 AM, thus spake "Bill Bumgarner" <b...@mac.com>: > >> I missed the OP's post.... >> >> If the static analyzer is barfing up a false positive, please report it >> (http://bugreport.apple.com/ works fine). > > Is that generally true? I mean, first of all, false positives are a > well-known phenomenon with this static analyzer (the Web page at llvm.org > talks about this). Second, they do no harm.
False positives do a lot of harm. For the reductio ad absurdum argument, imagine if the analyzer threw out a false positive on every line of your code. That would obviously make the tool completely worthless, as you would never be able to find the true positives. For a more realistic argument, consider that each false positive increases your mental load, increases the probability that you'll inadvertently ignore a true positive, and overall increases the cost and reduces the benefit of using the analyzer. The ultimate goal of such a tool should be zero false positives and zero false negatives. This is of course impossible, but they are *both* harmful, and it's a good thing to reduce each of them. > I get a false positive in *any* > of my apps that uses NSURLConnection, for example: > > NSURLConnection* con = [[NSURLConnection alloc] initWithRequest:req > delegate:self]; > > That triggers a "potential leak" warning. Well, of course it is a > *potential* leak. But it isn't a *real* leak, because I happen to know that > I'm going to release this object in either connection:didFailWithError: or > connectionDidFinishLoading:. (My code and memory management come right out > of Apple's own examples here.) I know how NSURLConnections work; the static > analyzer doesn't. But I would hardly call that a bug. I would call it potentially dangerous code. It's much better, IMO, to place the connection into an instance variable and that way balance all of your retains and releases. Each exception to the standard memory management pattern that you make increases the odds of screwing something up. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com