[LLVMbugs] [Bug 20390] New: Convenience initializers warn incorrectly with -Wobjc-designated-initializers when returning a new object

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 21 14:40:16 PDT 2014


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

            Bug ID: 20390
           Summary: Convenience initializers warn incorrectly with
                    -Wobjc-designated-initializers when returning a new
                    object
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tjw at me.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Convenience initializers should be able to call *zero* other initializers if
they are creating a new object. But, -Wobjc-designated-initializers incorrectly
warns when the returned object is _not_ self.

For example, if I have a silly category on NSNumber with:

- initZero;
{
    return [[NSNumber alloc] initWithInt:0];
}

then it is reasonable to not warn here since the returned object will have had
proper initialization (while the original 'self' will just get -release from
ARC). I've seen one instance in ~20 years (NSTextStorage) where deallocating an
object that didn't get an -init would crash. I'm assuming this isn't the case
this warning is trying to catch, but rather when you forget to fully initialize
the object that is returned (not an issue here since 'self' isn't returned).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140721/1b3854c2/attachment.html>


More information about the llvm-bugs mailing list