http://llvm.org/bugs/show_bug.cgi?id=11778
Bug #: 11778
Summary: incorrectly narrowing switch cases before checking for
duplicates
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
<stdin>:1:34: warning: overflow converting case value to switch condition type
(256 to 0) [-Wswitch]
int f(char c) { switch(c) { case 256: case 0: return 1; } return 0; }
^
<stdin>:1:44: error: duplicate case value '0'
int f(char c) { switch(c) { case 256: case 0: return 1; } return 0; }
^
<stdin>:1:34: note: previous case defined here
int f(char c) { switch(c) { case 256: case 0: return 1; } return 0; }
^
This is incorrect: the promoted type of the switch condition is 'int', and
there are no duplicate case values in this switch statement. The warning is
also incorrect, but it seems wise to produce some kind of warning for this
case: 'condition value can never equal case value' or similar.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs