[llvm-bugs] [Bug 35009] New: -Wtautological-constant-compare warning misleading on enum type

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 20 00:37:21 PDT 2017


            Bug ID: 35009
           Summary: -Wtautological-constant-compare warning misleading on
                    enum type
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mattias.v.eriksson at ericsson.com
                CC: llvm-bugs at lists.llvm.org

This program:

int foo() {
  enum E {a = 7} e = 1000;
  return e > 7;

Gives a warning when compiled with:

clang -Wtautological-constant-compare ee.c -S
ee.c:3:12: warning: comparison 'enum E' > 7 is always false
  return e > 7;
         ~ ^ ~

The warning is a bit misleading because the comparison is only tautological
when e is assigned a value defined in the enum. Maybe it would make sense to
have the tautology check be on the enum's underlying type.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171020/94642363/attachment-0001.html>

More information about the llvm-bugs mailing list