[LLVMbugs] [Bug 11778] New: incorrectly narrowing switch cases before checking for duplicates
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jan 16 19:38:58 PST 2012
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: unassignedclangbugs at nondot.org
ReportedBy: richard-llvm at metafoo.co.uk
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
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.
More information about the llvm-bugs
mailing list