Re: Static analyzer making unwarranted assumptions about ivars
Re: Static analyzer making unwarranted assumptions about ivars
- Subject: Re: Static analyzer making unwarranted assumptions about ivars
- From: Wim Lewis <email@hidden>
- Date: Tue, 15 Mar 2016 13:27:11 -0700
On Mar 15, 2016, at 12:14 PM, Jens Alfke <email@hidden> wrote:
> I added the assertion to try to make the warning go away, but it doesn’t go away. However, if I move the assert call down to below the NSLog, the warning goes away. It looks as though the analyzer believes that calling NSLog can change _foo to nil somehow.
It might be the assert() that is bringing the warning to light. If you have code that considers the possibility of nil, then the analyzer assumes that it could be nil. If your code doesn't consider the possibility of nil, then the analyzer frequently won't, either.
The analyzer has the same problem in other situations not involving pointers, for example if you have an integer argument that's used in a way that requires it to not be zero. Clang won't warn that it could be zero... *unless* you test whether it's zero, then it starts to complain.
Yes, this seems backwards, but it is the behavior Apple intends (as described by Devin in this thread and my radars returned as WONTFIX).
_______________________________________________
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