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

            Bug ID: 62153
           Summary: warn for bool expression compared with integer
                    different from 0/1
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manu at gcc dot gnu.org

#define X(x) (x == 1)

void foo(void)
{
  int a;
  if (X(a) == 2) {
    return;
  }
}

Clang++ warns for this by default:

test.c:6:12: warning: comparison of constant 2 with expression of type 'bool'
is always false [-Wtautological-constant-out-of-range-compare]
  if (X(a) == 2) {
      ~~~~ ^  ~

Reply via email to