https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65423

            Bug ID: 65423
           Summary: No warning on always-true/false predicates containing
                    bitwise operations
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

The condition "(a & 9) == 4" is always false, and it will be great if Gcc can
emit a warning on this. 

$: cat bitwise.c 
int f(int a) {
  if ((a & 9) == 4) {
    return 1;
  } else {
    return 0;
  }
}
$: clang-trunk -Wtautological-compare -c bitwise.c 
bitwise.c:2:15: warning: bitwise comparison always evaluates to false
      [-Wtautological-compare]
  if ((a & 9) == 4) {
      ~~~~~~~~^~~~
1 warning generated.
$: gcc-trunk -Wall -Wextra -Wtype-limits -c bitwise.c

Reply via email to