https://llvm.org/bugs/show_bug.cgi?id=27680

            Bug ID: 27680
           Summary: warning when comparing enum with constant in C
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: pgr...@redhat.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

When compiling C code:

typedef enum {
    A=0,
} my_enum;

int f(my_enum x) {
    if (x <= 1)
        return -1;
    return 0;
}

with -Wall a -Wtautological-constant-out-of-range-compare warning is produced.
However changing code to:

typedef enum {
    A=1,
} my_enum;

int f(my_enum x) {
    if (x <= 1)
        return -1;
    return 0;
}

No warning is produced. So there seems to be some inconsistency.
Personally I would remove the warning for enum comparison when compiling C code
at all - in C enums and ints can be mixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to