Re: why doesn't the compiler complain?
Re: why doesn't the compiler complain?
- Subject: Re: why doesn't the compiler complain?
- From: "Paul Sanders" <email@hidden>
- Date: Tue, 27 Apr 2010 11:06:19 +0100
> So I guess the compiler treats the *first* declaration of a
> method
> name-and-signature that it encounters as the "real" one.
>
> Now, that's okay ...
Not really. Without the warning flag it means that the type
checking you would hope to get from the compiler is subverted.
In your example it might let you pass an NSString to a method
expecting an NSArray, which is likely to have unfortunate
results. Other, more insidious examples, are possible,
including cases that could lead to a memory overwrite. I think
the fact that the warning is off by default is probably for
historical reasons. I'd like to see that changed.
Unfortunately, setting it project-wide generates a warning
(something like 'this flag pertains only to Objective-C') for .c
and .cpp files, which is a bit of a pain, but one can probably
set it with a #pragma.
Paul Sanders.
_______________________________________________
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