[LLVMbugs] [Bug 11293] New: Objective-C init method with return type id unable to return parent object type pointer

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 1 23:59:47 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=11293

             Bug #: 11293
           Summary: Objective-C init method with return type id unable to
                    return parent object type pointer
           Product: new-bugs
           Version: unspecified
          Platform: Macintosh
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: muthuveerappan.al at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 7572
  --> http://llvm.org/bugs/attachment.cgi?id=7572
Objective-C example showing that the init method with return type id is unable
to return parent object type pointer

Objective-C init method with return type id unable to return parent object type
pointer

id type can represent the pointer to any object

When an init method (with a return type "id") of a subclass returns a parent
class pointer, the compiler throws a warning / error.

However when another method without the prefix "init" does the same no
compilation error / warning is thrown.

Actual Behavior
============
When an init method (with a return type "id") of a subclass returns a parent
class pointer, the compiler throws a warning / error

Expected Behavior
===============
When an init method (with a return type "id") of a subclass returns a parent
class pointer, the compiler should not throw a warning / error

Example (Sample Objective-C program explaining the problem)
===============================================
Pls see the attached Objective-C program that explains the problem

Reference:
==========
The Objective‐C Programming Language (Page 14)

Quoted from the document:

"In Objective-C, object identifiers are of a distinct data type: id. This type
is the general type for any kind of object regardless of class and can be used
for instances of a class and for class objects themselves."

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list