[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

mattias.v.eriksson@ericsson.com via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 10:02:14 PDT 2017


materi added a comment.

Hi!

After this patch I started to see warnings:

  e.c:8:23: warning: integer constant not in range of enumerated type 'enum E' [-Wassign-enum]
    enum E {a = 7,} e = 1000;
                        ^
  e.c:10:12: warning: comparison 'enum E' > 7 is always false [-Wtautological-constant-compare]
    return e > 7;

Isn't the the "always false" message misleading? It's only "always false" if e was initialized with an in-range value. Maybe the tautology check should be on the enum's underlying type instead?


Repository:
  rL LLVM

https://reviews.llvm.org/D38101





More information about the cfe-commits mailing list