[llvm-bugs] [Bug 25235] New: clang-analyzer-core.uninitialized.Assign doesn't understand bits sets/read operations
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Oct 18 10:55:37 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=25235
Bug ID: 25235
Summary: clang-analyzer-core.uninitialized.Assign doesn't
understand bits sets/read operations
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: gonzalobg88 at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Given an uninitialized variable:
uint32_t var;
and a function to set the i-th bit of var to a value:
template <typename Int>
constexpr void set(Int& x, unsigned b, bool value) {
static_assert(std::is_integral<Int>{}, "");
assert(bit < CHAR_BIT * sizeof(Int{}));
if (value) {
x |= (Int{1} << b);
} else {
x &= ~(Int{1} << b);
}
}
Then static analyzer complains when:
set(var, 3, true);
is used to set the 3rd bit of var to true because set reads and writes not only
the 3rd bit, but obviously the whole variable, which is uninitialized.
Probably static_analyzer will also fail when reading the 3rd bit back from var.
Since bit operations and bit masks are very common, static analyzer should
probably track the bits or at least understand the basic bit manipulation
operations.
--
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/20151018/eb54cfb0/attachment-0001.html>
More information about the llvm-bugs
mailing list