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 objc-langu...@lists.apple.com is probably the correct place to ask these 
questions.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to