[llvm-bugs] [Bug 51216] New: warn about bitwise instead of logical and
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 26 02:36:24 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51216
Bug ID: 51216
Summary: warn about bitwise instead of logical and
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: hans at chromium.org
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
Such a warning would have caught this issue:
https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3039560/2/cryptohome/vault_keyset.cc#471
Consider:
$ cat /tmp/a.cc
bool foo(); bool bar(); void baz();
int main() {
if (foo() & bar())
baz();
return 0;
}
I thought Clang might have an off-by-default warning about this, but it seems
not:
$ clang -c /tmp/a.cc -Weverything
(no warning)
To reduce the false-positive rate, one could consider triggering only on
boolean expressions, or expressions with potential side effects, or only inside
if expressions, etc.
--
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/20210726/3582bed4/attachment.html>
More information about the llvm-bugs
mailing list