<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 --- - variable reassignment in switch not detected ?"
   href="http://llvm.org/bugs/show_bug.cgi?id=20950">20950</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>variable reassignment in switch not detected ?
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dcb314@hotmail.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>Given the following source code

void f(int n)
{
    int m;

    switch (n)
    {
    case 1: m = 2;
    case 2: m = 3;
    case 3: m = 4;
    case 4: m = 5;
    }
}

Here is trunk clang++:

$ ~/llvm/results/bin/clang++ -c -g -O2 -Wall jun23b.cc
$

Here is trunk gcc warning about something else:

$ ~/gcc/results/bin/g++ -c -g -O2 -Wall jun23b.cc
jun23b.cc: In function ‘void f(int)’:
jun23b.cc:4:6: warning: variable ‘m’ set but not used
[-Wunused-but-set-variable]
  int m;
      ^
$

And here is trunk cppcheck finding the problem

$ ~/cppcheck/trunk/cppcheck --enable=all jun23b.cc
Checking jun23b.cc...
[jun23b.cc:8] -> [jun23b.cc:9]: (warning) Variable 'm' is reassigned a value
before the old one has been used. 'break;' missing?
[jun23b.cc:9] -> [jun23b.cc:10]: (warning) Variable 'm' is reassigned a value
before the old one has been used. 'break;' missing?
[jun23b.cc:10] -> [jun23b.cc:11]: (warning) Variable 'm' is reassigned a value
before the old one has been used. 'break;' missing?
$</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>