[llvm-bugs] [Bug 28872] New: Missing uninitialized variable warning.
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Aug 5 09:10:26 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28872
Bug ID: 28872
Summary: Missing uninitialized variable warning.
Product: clang
Version: unspecified
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: mathieu.bosi at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Hi
Code such as:
int main(void)
{
int value = value; // value is garbage, no warning is generated
return 0;
}
Does not trigger any warning.
Using the uninitialized value to access an array or any STL container (e.g.
std::map) does not trigger any warnings either.
e.g.
std::map<int> hashmap;
int foo = hashmap[foo];
On the other hand, the proper warning appears in code like this:
int foo(int bar)
{
return bar;
}
int main(void)
{
int value = foo(value); // <-- proper warning is generated
}
I'm not even sure why C++ allows such syntax (maybe some kind of shortcut for
non plain-old-data / classes?) but it sure caused a (easy to track down) bug in
the code I was working on.
NOTE: I did not know which clang version to select from the Bugzilla spinner.
'clang --version' returns:
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
Cheers
--
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/20160805/fed3db20/attachment.html>
More information about the llvm-bugs
mailing list