[llvm-bugs] [Bug 27680] New: warning when comparing enum with constant in C
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 9 01:46:59 PDT 2016
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: unassignedclangbugs at nondot.org
Reporter: pgrunt at redhat.com
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160509/e8f41a4c/attachment.html>
More information about the llvm-bugs
mailing list