[LLVMbugs] [Bug 9094] New: Assigning to self twice in init provokes spurious warning about not assigning at all
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jan 28 11:37:32 PST 2011
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: unassignedclangbugs at nondot.org
ReportedBy: tjw at omnigroup.com
CC: llvmbugs at cs.uiuc.edu
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.
More information about the llvm-bugs
mailing list