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

           Summary: Assigning to self twice in init provokes spurious
                    warning about not assigning at all
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


A common pattern in classes with multiple initializers (for example NSView with
-initWithFrame: and -initWithCoder:) is to put the subclass's common
initialization bits into a static function. If you structure this so that the
common init can fail and return nil, then you can end up with something like
this:


- init;
{
    if (!(self = [super init]))
        return nil;
    if (!(self = _commonInit(self)))
        return nil;

    return self;
}


This provokes a warning about never having assigned self before returning it,
which is not true:

 double-assign-self.m:28:5: warning: Returning 'self' before setting it to the
result of '[(super or self) init...]'

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to