[LLVMbugs] [Bug 13101] New: clang should warn on condition which is always true

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 13 05:13:43 PDT 2012


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

             Bug #: 13101
           Summary: clang should warn on condition which is always true
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dlmeetei at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The simple test case, where 
> p[0] != 'h' || p[0] != 'H'
is always true, is not warned by clang++ and g++ too. 

It will nice, If we have some flag like -Walways-true, which should warn on
such usage. 
This will churn out silly bugs. 

tested with the following code. 

int main()
{
        char *p ="Hello World\n";
        if(p[0] != 'h' || p[0] != 'H')
        {
                cout << "Word does not start with h/H\n";
        }
        return 0;
}

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