Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-08 Thread Charles Srstka
> On May 8, 2015, at 2:43 AM, Daniel Höpfl wrote: > > a) > @property (assign, nonatomic, readonly) GridCycler *cycler; > > init: > _cycler = [[GridCycler alloc] initWithGrid: self]; > > dealloc: > [_cycler release]; Why are we presenting an assign property as the first (and presumably, default

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-08 Thread Daniel Höpfl
On 07.05.2015 20:16, Charles Srstka wrote: > On May 7, 2015, at 6:44 AM, Daniel Höpfl > wrote: >> >> I'd change the code as follows: >> >> // init >> self.cycler = [[[GridCycler alloc] initWithGrid: self] autorelease]; >> >> // alternative init, if you want to bypass the au

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-07 Thread Charles Srstka
On May 7, 2015, at 6:44 AM, Daniel Höpfl wrote: > > I'd change the code as follows: > > // init > self.cycler = [[[GridCycler alloc] initWithGrid: self] autorelease]; > > // alternative init, if you want to bypass the autorelease pool: > > GridCycler *cycler = [[GridCycler alloc] initWithGrid:

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-07 Thread Daniel Höpfl
Hi, Expanding the "potential leak" message yields: Static analyser is right, there is a potential leak. Based on what Aaron said, assume the following usage of your class: LifeGrid *grid = [[LifeGrid alloc] init]; // GridCycler is allocated (retain count: +1) // GridCycler is retained by pro

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Michael David Crawford
I agree that it's inappropriate to expect that the analyzer will assume that the getters and setters work the way they conventionally do. One reason we have properties is so that, when required, they can do other things: - (void) setAdversary: (int)enemy { _enemy = enemy; [_enemy setUpTh

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Ken Thomases
On May 6, 2015, at 4:40 PM, Aaron Montgomery wrote: > If the property is set to "retain", then the line > > self.cycler = [[[….initWithGrid:self] autorelease] > > will cause the setter to retain the passed in object, so after this line, > _cycler will have a (heuristic) retain count of 2 (an a

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Aaron Montgomery
If the property is set to "retain", then the line self.cycler = [[[….initWithGrid:self] autorelease] will cause the setter to retain the passed in object, so after this line, _cycler will have a (heuristic) retain count of 2 (an alloc and a retain). After this, when the autorelease pool is drai

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Michael David Crawford
John McCall wrote: > You should probably make the property readonly and just directly assign to > the ivar in -init. That works. In this particular case, it might make more sense for my property to be just a regular ivar, without a getter and setter. That is, my grid object owns a cycler objec

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread John McCall
> On May 6, 2015, at 1:57 PM, Michael David Crawford > wrote: > I've had problems in the past where I failed to understand the Cocoa > ownership conventions, I'm willing to grant that could be the case. > > I know for sure that the analyzer enforces the naming conventions, > that is, the exact s

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Ken Thomases
On May 6, 2015, at 3:57 PM, Michael David Crawford wrote: > // LifeGrid.h > @property (assign, nonatomic) GridCycler *cycler; > > // Lifegrid.m - init > self.cycler = [[GridCycler alloc] initWithGrid: self]; // Potential > leak of an object > if ( nil == self.cycler ) goto cycler_failed; > > /

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Greg Parker
> On May 6, 2015, at 2:17 PM, Michael David Crawford > wrote: > > This is 6.2. I speculated a different diagnostic was a bug; were it > correct, I would have seen that same diagnostic on some other code. > > I'll file a radar with a minimal test case if you'd like me to. > > I'll download 6.

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Michael David Crawford
This is 6.2. I speculated a different diagnostic was a bug; were it correct, I would have seen that same diagnostic on some other code. I'll file a radar with a minimal test case if you'd like me to. I'll download 6.3.1 right now. Michael David Crawford, Consulting Software Engineer mdcrawf...@g

Re: static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Greg Parker
> On May 6, 2015, at 1:57 PM, Michael David Crawford > wrote: > > // LifeGrid.h > @property (assign, nonatomic) GridCycler *cycler; > > // Lifegrid.m - init > self.cycler = [[GridCycler alloc] initWithGrid: self]; // Potential > leak of an object > if ( nil == self.cycler ) goto cycler_failed

static analyzers says I'm leaking, I _think_ I'm not

2015-05-06 Thread Michael David Crawford
I've had problems in the past where I failed to understand the Cocoa ownership conventions, I'm willing to grant that could be the case. I know for sure that the analyzer enforces the naming conventions, that is, the exact same function names in C or C++ won't yield that same warnings as "alloc",