• 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: spurious clang warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: spurious clang warning


  • Subject: Re: spurious clang warning
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 08 Dec 2011 09:46:38 -0800

On Dec 8, 2011, at 00:53 , Jean-Denis MUYS wrote:

Anyway, clang (3.0) doesn't like my method and complains that "Incompatible pointer types returning 'Abstract *__strong' from a function with result 'Concrete1*'". This warning (fortunately not an error) seems mistaken to me.

See here:

http://clang.llvm.org/docs/AutomaticReferenceCounting.html#family.semantics.result_type

which says:

Certain methods are candidates to have related result types:

  • class methods in the alloc and new method families
  • instance methods in the init family
  • the instance method self
  • outside of ARC, the instance methods retain and autorelease

If the formal result type of such a method is id or protocol-qualified id, or a type equal to the declaring class or a superclass, then it is said to have a related result type. In this case, when invoked in an explicit message send, it is assumed to return a type related to the type of the receiver:

  • if it is a class method, and the receiver is a class name T, the message send _expression_ has type T*; otherwise
  • if it is an instance method, and the receiver has type T, the message send _expression_ has type T; otherwise
  • the message send _expression_ has the normal result type of the method.

This is a new rule of the Objective-C language and applies outside of ARC.

If you don't want to follow this rule, you'll either need to use a different name for your method, or qualify it with '__attribute__((objc_method_family(none)))' as described in section 5.1.



 _______________________________________________
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

References: 
 >spurious clang warning (From: Jean-Denis MUYS <email@hidden>)

  • Prev by Date: Re: FleMerge: how to merge two different files [SOLVED]?
  • Next by Date: Re: How to debug or run an IOS application without source code in Xcode4
  • Previous by thread: spurious clang warning
  • Next by thread: How to debug or run an IOS application without source code in Xcode4
  • Index(es):
    • Date
    • Thread