[LLVMbugs] [Bug 16615] New: false positive: static analyzer does not detect full case

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jul 13 02:20:17 PDT 2013


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: kremenek at apple.com
          Reporter: pat.pannuto at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130713/66d2b7f3/attachment.html>


More information about the llvm-bugs mailing list