<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - false positive: static analyzer does not detect full case"
   href="http://llvm.org/bugs/show_bug.cgi?id=16615">16615</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>false positive: static analyzer does not detect full case
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>pat.pannuto@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=10877" name="attach_10877" title="Minimum working example">attachment 10877</a> <a href="attachment.cgi?id=10877&action=edit" title="Minimum working example">[details]</a></span>
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    }</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>