• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: why doesn't the compiler complain?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: why doesn't the compiler complain? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: NSApplicationMain question
  • Next by Date: NewMovieFromDataRef crashes when QT movie URL is not found
  • Previous by thread: Re: why doesn't the compiler complain?
  • Next by thread: Re: why doesn't the compiler complain?
  • Index(es):
    • Date
    • Thread