<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 null pointer dereference with integer arithmetic"
   href="http://llvm.org/bugs/show_bug.cgi?id=15855">15855</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>False positive null pointer dereference with integer arithmetic
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>bugzilla@jwwalker.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>Overview:

I get a null pointer dereference warning that assumes a certain variable is
negative, when in fact one can easily deduce that the variable cannot be
negative.


Steps to reproduce:

Analyze this code:

-------------------------
static void Foo( int numFaces )
{
    int* ptr = 0;

    int absFaces;
    if (numFaces > 0)
    {
        absFaces = numFaces;
    }
    else
    {
        absFaces = - numFaces;
    }

    if (absFaces < 0)
    {
        *ptr = 99;
    }
}
-------------------------


Actual results:

"Dereference of null pointer (loaded from variable 'ptr')
  'ptr' initialized to a null pointer value
  Assuming 'numFaces' is <= 0
  Assuming 'absFaces' is < 0"


Expected results:

No warnings, or maybe something saying that a line is unreachable.


Build date:

clang version 3.3 (trunk 180622)
Target: x86_64-apple-darwin11.4.2
Thread model: posix</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>