http://llvm.org/bugs/show_bug.cgi?id=16615
Bug ID: 16615
Summary: false positive: static analyzer does not detect full
case
Product: clang
Version: 3.2
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Created attachment 10877
--> http://llvm.org/bugs/attachment.cgi?id=10877&action=edit
Minimum working example
$ clang --version
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
checker-275 pre-compiled bundle for mac.
-----
The static analyzer does not detect case statements that are full, that is all
possible values are explicitly listed as cases and a default block is
unnecessary / impossible to reach:
For the following MWE, out is always well-defined despite the static analyzer's
protestations to the contrary:
1 #include <stdio.h>
2
3 int main(int argc, char **argv) {
4 int val = argc;
5 int out;
1
'out' declared without an initial value
→
6
7 switch (val & 0x3) {
2
←
'Default' branch taken. Execution continues on line 25
→
8 case 0x0:
9 out = 0;
10 break;
11
12 case 0x1:
13 out = 1;
14 break;
15
16 case 0x2:
17 out = 2;
18 break;
19
20 case 0x3:
21 out = 3;
22 break;
23 }
24
25 printf("Out is %d\n", out);
3
←
Function call argument is an uninitialized value
26 }
--
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