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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
Clang warns when an enum object is compared to a constant that's out of the
most restricted range of the enum's type.  The warning is in -Wall.  It doesn't
warn when the object is compared to a constant that doesn't correspond to any
of the type's enumerators.  I can see that being useful to some (carefully
written) projects but suspect it could be quite noisy for many others.

$ cat t.C && clang++ -S -Wall -Wextra t.C
enum E { NONE = 0, ONE = 1, TWO = 2 };

bool f (E e)
{
  return e == 3;   // no warning here
}

bool g (E e)
{
  return e == 4;
}


t.C:10:12: warning: comparison of constant 4 with expression of type 'E' is
      always false [-Wtautological-constant-out-of-range-compare]
  return e == 4;
         ~ ^  ~
1 warning generated.

Reply via email to