http://llvm.org/bugs/show_bug.cgi?id=9062
Summary: -Wuninitialized false positive
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
chrome code:
bool found = false;
const char *pair;
for (unsigned i = 0; env[i]; i++) {
pair = env[i];
const char *const equals = strchr(pair, '=');
if (!equals)
continue;
const unsigned keylen = equals - pair;
if (keylen == j->first.size() &&
memcmp(pair, j->first.data(), keylen) == 0) {
found = true;
break;
}
}
// if found, we'll either be deleting or replacing this element.
if (found) {
count--;
size -= strlen(pair) + 1;
if (j->second.size())
found = false;
}
clang complains:
/Volumes/MacintoshHD2/src/chrome-git/src/base/process_util_posix.cc:378:11:
error: use of uninitialized variable 'pair' [-Wuninitialized]
const char *pair;
^~~~~~~~~~
/Volumes/MacintoshHD2/src/chrome-git/src/base/process_util_posix.cc:396:22:
note: variable 'pair' is possibly uninitialized when used here
size -= strlen(pair) + 1;
^~~~
/Volumes/MacintoshHD2/src/chrome-git/src/base/process_util_posix.cc:378:21:
note: add initialization to silence this warning
const char *pair;
^
= 0
1 error generated.
…but the access happens only if |found| is true, and in that case the pointer
is always initialized.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- 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