<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 logic error with float variable"
   href="http://llvm.org/bugs/show_bug.cgi?id=15985">15985</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>false positive logic error with float variable
          </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:

The static analyzer reports that a variable is used uninitialized, in a
situation where it can't be.


Steps to reproduce:

Analyze this C++ code:

-------------------------------
#include <vector>

static int Foo( std::vector<int>& things )
{
    int result = 0;
    int blah;

    float maxDist = -10000;

    if (things.empty())
    {
        maxDist = 1;
        blah = 9;
    }

    if (maxDist > 0)
    {
        result = blah + 2;
    }

    return result;
}
-------------------------------


Actual results:

warning: The left operand of '+' is a garbage value
(pointing to the assignment result = blah + 2)


Expected results:

No warnings.


Build date:

clang version 3.4 (trunk 181711)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

Additional information:

Note that if the vector is empty, then blah will have a value assigned to it,
whereas if the vector is not empty, the assignment to result will not be
reached.

If I change the type of maxDist from float to int, the warning goes away.</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>