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

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 10:26:51 PDT 2017


lebedev.ri added a comment.

In https://reviews.llvm.org/D38101#901709, @materi wrote:

> Hi!


Hi.

> After this patch I started to see warnings:

Thank you for the report!

>   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?

I agree, please open a bug, i'll look into this.


Repository:
  rL LLVM

https://reviews.llvm.org/D38101





More information about the cfe-commits mailing list