• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Analyzer warning about garbage with double return values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Analyzer warning about garbage with double return values
      • From: "Sean McBride" <email@hidden>
    • Re: Analyzer warning about garbage with double return values
      • From: Roland King <email@hidden>
References: 
 >Analyzer warning about garbage with double return values (From: Markus Spoettl <email@hidden>)
 >Re: Analyzer warning about garbage with double return values (From: Jonas Maebe <email@hidden>)
 >Re: Analyzer warning about garbage with double return values (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Analyzer warning about garbage with double return values (From: Bjoern Knafla <email@hidden>)
 >Re: Analyzer warning about garbage with double return values (From: Markus Spoettl <email@hidden>)
 >Re: Analyzer warning about garbage with double return values (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Analyzer warning about garbage with double return values (From: Markus Spoettl <email@hidden>)
 >Re: Analyzer warning about garbage with double return values (From: Roland King <email@hidden>)

  • Prev by Date: error: can't exec '/Developer/usr/bin/gcc-4.2' (No such file or directory)
  • Next by Date: Re: error: can't exec '/Developer/usr/bin/gcc-4.2' (No such file or directory)
  • Previous by thread: Re: Analyzer warning about garbage with double return values
  • Next by thread: Re: Analyzer warning about garbage with double return values
  • Index(es):
    • Date
    • Thread