Re: Static Analyzer is confusing me
Re: Static Analyzer is confusing me
- Subject: Re: Static Analyzer is confusing me
- From: Quincey Morris <email@hidden>
- Date: Tue, 01 Mar 2011 00:16:12 -0800
On Feb 28, 2011, at 22:47, Gerriet M. Denkmann wrote:
> Why does this error message go away when I add:
> #define MAKE_BUG_DISAPPEAR1 3
>
> Why does it NOT go away with:
> #define MAKE_BUG_DISAPPEAR1 2 // or anything less than 3 ? What is so magical about 3?
I'd guess that the static analyzer "thinks" in terms of the first pass through a loop, the second pass through the loop, and subsequent passes through the loop. (Maybe also the last pass, the 2nd last pass, and earlier passes.) If something like that's true, then looping 3 or more times might convince it that the array is fully initialized. (This is in the case when the array size is "unknown", see below.)
> Why does this error message go away when I add:
> #define MAKE_BUG_DISAPPEAR2
I think because declaring the array size 'const' allows the analyzer to know the actual value at the time 'aBug' is entered. Without that, the static variable might have been altered since initialization, so the analyzer can't assume anything about its value.
> Is this correct Objective-C or not?
I believe this is a C question, not an Objective-C question, and I'm not a C spec expert, but I think variable sized arrays are a non-spec extension that GCC implemented, and hence is an extension in Clang too. The compiler complaints might also vary with which C spec version the compiler is using (C89, C99, etc).
List email@hidden is probably the correct place to ask these questions.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden