Re: Analyzer warning about garbage with double return values
Re: Analyzer warning about garbage with double return values
- Subject: Re: Analyzer warning about garbage with double return values
- From: Bill Bumgarner <email@hidden>
- Date: Wed, 02 Sep 2009 08:09:17 -0700
On Sep 2, 2009, at 4:28 AM, Roland King wrote:
I have a similar issue - in this case I'm setting a variable to nil
early in the routine, just when I declare it, however it's
guaranteed to get set later to something else (whilst iterating a
set of touches which are guaranteed not to be empty). I get the same
message about sending messages to nil as the static analyzer can't
prove to itself the variable is ever reset.
Welcome to the exciting world of edge cases galore!
The static analyzer generally does a wonderful job of indicating
potential problems. There are a handful of cases where it doesn't
get the rules quite right; typically with exceptional cases and, in
particular, in cases where state is only guaranteed because the docs
say it'll work that way and code you don't have is implemented that way.
Please file a bug via http://bugreport.apple.com/. The component is
"llvm - checker".
Note that this is one area where it isn't totally clear how the
analyzer should be fixed. In particular, while the docs say that the
touches are guaranteed to not be empty, what if a bug -- yours or
Apple's -- causes them to be? Would a better solution be to add an
assert() at the beginning of the method, one that isn't compiled into
production code? A strong argument could be made for that being a
preferable solution in that it explicitly quantifies the documented
behavior into the code.
(Even for the handful of static analysis false positives, the tool has
proven to be incredibly valuable. A total game changer in my code,
certainly.)
b.bum
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden