[LLVMbugs] [Bug 10444] New: False -Wunreachable-code warning in switch(typedefEnum) for default:
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jul 22 14:36:33 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10444
Summary: False -Wunreachable-code warning in
switch(typedefEnum) for default:
Product: clang
Version: unspecified
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: john.engelhart at gmail.com
CC: llvmbugs at cs.uiuc.edu
There is a false -Wunreachable-code warning when a switch() statement has a
`typedef enum` as its argument and all of the declared `enum` types have a
`case ...:` statement for them.
In this case, clang will give an unreachable warning if the `switch() { }`
statement contains a `default:`, which clang will incorrectly warn that the
`default:` case is not reachable.
This is on a Mac OS X 10.7 system running clang from Xcode 4.2 Build 4D75.
shell% uname -a
Darwin anonymous.local 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35
PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64
shell% /Developer4/usr/bin/clang --version
Apple clang version 3.0 (tags/Apple/clang-210.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.0.0
Thread model: posix
shell% /Developer4/usr/bin/clang -Wunreachable-code -fsyntax-only enumBug.c
enumBug.c:17:7: warning: will never be executed [-Wunreachable-code]
printf("default, an enum value that is not defined.\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
// enumBug.c
#include <stdio.h>
typedef enum {
XYEnumOne,
XYEnumTwo,
} XYEnumBug;
XYEnumBug enumBug;
int main(int argc, char *argv[]) {
switch(enumBug) {
case XYEnumOne:
case XYEnumTwo:
printf("a defined enum value\n");
break;
default:
printf("default, an enum value that is not defined.\n");
break;
}
return(0);
}
--
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