[LLVMbugs] [Bug 19494] New: Incorrect diagnostic issued by -Wunreachable-code for switch case on enums
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Apr 20 08:21:17 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19494
Bug ID: 19494
Summary: Incorrect diagnostic issued by -Wunreachable-code for
switch case on enums
Product: clang
Version: 3.2
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: eyal.lotem at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 12414
--> http://llvm.org/bugs/attachment.cgi?id=12414&action=edit
Small test case
A comprehensive switch(enum_value) that has a case for each named enum value,
all of which have a "return" confuses clang. It believes that no possible
runtime value is possible besides the named enum values, however this is
incorrect. C (and clang) allow enum-typed variables to be assigned from
non-named values of the enum.
The test case compiles into a correct executable, but if compiled with
-Wunreachable-code, issues an incorrect warning like:
clang -Wunreachable-code -o testclangunreachable testclangunreachable.c &&
./testclangunreachable
testclangunreachable.c:11:12: warning: will never be executed
[-Wunreachable-code]
printf("Unreachable code reached!\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
Unreachable code reached!
--
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/20140420/9592a538/attachment.html>
More information about the llvm-bugs
mailing list