[llvm-bugs] [Bug 49381] New: [analyzer] EnumCastOutOfRange false-positive for bitmasks
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 1 08:55:31 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49381
Bug ID: 49381
Summary: [analyzer] EnumCastOutOfRange false-positive for
bitmasks
Product: clang
Version: 11.0
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: dcoughlin at apple.com
Reporter: balazs.benics at sigmatechnology.se
CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org
The EnumCastOutOfRange checker emits a warning for this code:
// -std=c++17 -Xclang -analyze -Xclang
-analyzer-checker=core,alpha.cplusplus.EnumCastOutOfRange -Xclang
-analyzer-output=text
https://godbolt.org/z/xosTxq
enum TestEnum {
A = 0,
B = 1,
C = 2,
D = 4,
};
void bitmasks() {
static_assert((B | C | D) == 7);
TestEnum t = static_cast<TestEnum>(7); // should not warn
(void)t;
}
The checker should recognize the bitmask and check the bounds accordingly.
/CC Endre Fülöp, the co-author of the checker
--
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/20210301/f4d9dcd3/attachment.html>
More information about the llvm-bugs
mailing list