[cfe-dev] Static Ananlyze, dead store false positive

Ted Kremenek kremenek at apple.com
Thu Jul 3 15:35:55 PDT 2008


On Jul 3, 2008, at 12:42 PM, Jean-Daniel Dupas wrote:

> I'm playing with the last static analyzer (I'm always working with  
> the svn trunk ;-)) and I'm scanning some of my projects.
> I confirm that it is a very valuable tool.
>
> I give you a fase positive (I think it 's one). It says I never read  
> values out of keys, but I'm using it twice in the condition.
>
>
> void DeadStoreTest(NSObject *anObject) {
>  NSArray *keys;
> // analyze result: Although the value stored to 'keys' is used in  
> the enclosing expression, the value is never actually read from 'keys'
>  if ((keys = [anObject exposedBindings]) &&
>      ([keys containsObject:@"name"] && [keys  
> containsObject:@"icon"])) {
>      // do something without keys
>
>  }
> }

This was a genuine bug in the Dead Stores checker, now fixed:

   http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080630/006378.html

For those not working with the SVN trunk, the fix should now be in  
checker-56 (on the Clang website).

BTW, this was an awesome test case.  It nicely exercised a mishandled  
corner case in the analyzer's logic, which allowed me to quickly  
diagnose the problem.  Thanks for providing it!

Ted



More information about the cfe-dev mailing list