[LLVMbugs] [Bug 14607] New: clang does not emit a warning when assigning properties in conditions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 14 03:37:13 PST 2012


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

             Bug #: 14607
           Summary: clang does not emit a warning when assigning
                    properties in conditions
           Product: clang
           Version: 3.2
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: mayer.julian at googlemail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


clang emits a nice warning when assigning in an condition:

"using the result of an assignment as a condition without parentheses"

however, this is only true for normal/member variables and direct property
access, not when accessing properties with dot notation:

@interface Test :  NSObject
  @property (assign, nonatomic) BOOL cond;
@end

@implementation Test

- (void)bugWithWarning
{// clang properly warns here "using the result of an assignment as a condition
without parentheses"
    if (_cond = YES) 
        NSLog(@"condition true");
}

- (void)bugWithoutWarning
{ // clang fails to warn here even with -Weverything. another bug gone
unnoticed.
    if (self.cond = YES)
        NSLog(@"condition true");
}
@end

-- 
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