<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Cristian,<div><br></div><div>Sorry for the delayed response.  This is indeed expected behavior.</div><div><br></div><div>The path analysis in the static analyzer involves essentially unrolling loops a finite number of times.  To ensure analysis termination, once a threshold is reached (3 iterations) the analysis of a given path is halted.  Since the reference to 'array' is live within the loop body, no leak is reported since we do not reach a point in the path where that reference is no longer live.</div><div><br></div><div>Fixing this requires gradually improving the analysis of loops, e.g., by increasing the termination threshold for loops of a fixed bound.  Changing the handling of loops in the analyzer, however, needs to be done with care as it can substantially effect analysis performance (with a tradeoff of bugs found/missed).  It's something I think deserves more attention in the future.</div><div><br></div><div>Cheers,</div><div>Ted</div><div><br><div><div>On Dec 31, 2009, at 12:01 AM, Cristian Draghici wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div>Hi</div><div><br></div><div>I've bumped into this recently and I can't find on <a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a></div><div><br></div><div>leak detected:</div><div><br></div><div><div>
       NSMutableArray *array = [[NSMutableArray alloc] init];</div><div>        [array addObject:@"W"];</div><div>        [array addObject:@"W"];</div>
<div><br></div></div></div><div>leak not detected when more then two iterations:</div><div>        NSMutableArray *array = [[NSMutableArray alloc] init];</div><div><br></div><div>        int i=0;</div><div>        for(i=0;i<3;i++)</div>
<div>                [array addObject:@"W"];</div>
<div><br></div><div>Is clang looking at a limited number of iterations and deciding defensively not to signal the leak?</div><div><br></div><div>Thanks,</div><div>Cristi</div><div><br></div>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></blockquote></div><br></div></body></html>