Improvements for Clang warning -Wtautological-overlap-compare (original) (raw)

Bugzilla Link 13101
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @chandlerc,@nico,@Weverything

Extended Description

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