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: [email protected]
Reporter: [email protected]
CC: [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs