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: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
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._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs