sqc 0.4.13

Software Code Quality - CERT C compliance checker
[metadata]
id = "EXP46-C"
type = "rule"
category = "EXP"
number = 46
title = "Do not use a bitwise operator with a Boolean-like operand"
description = """
Mixing bitwise and relational operators in the same full expression can be a
sign of a logic error in the expression where a logical operator is usually the
intended operator. Do not use the bitwise AND (&), bitwise OR (|), or bitwise
XOR (^) operators with an operand of type_Bool, or the result of arelational-
expressionorequality-expression. If the bitwise operator is intended, it should
be indicated with use of a parenthesized expression. In this noncompliant code
example, a bitwise&operator is used with the results of twoequality-expressions:
if (getuid() == 0 & getgid() == 0) { /* ... */ }
"""
severity = "Low"
likelihood = "Likely"
priority = "P9"
level = "L2"
cert_version = "2016 Edition (Wiki)"
last_modified = "Oct 29, 2025"

[rules.cert_c.EXP46-C]
enabled = true

[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/EXP46-C.+Do+not+use+a+bitwise+operator+with+a+Boolean-like+operand"
cwe = ["CWE-480", "CWE-569"]