[LLVMbugs] [Bug 15985] New: false positive logic error with float variable
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon May 13 14:20:22 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=15985
Bug ID: 15985
Summary: false positive logic error with float variable
Product: clang
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: bugzilla at jwwalker.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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.
--
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/20130513/76c2a60b/attachment.html>
More information about the llvm-bugs
mailing list