CWE-482

Comparing instead of Assigning
AI Translation Available

The code uses an operator for comparison when the intention was to perform an assignment.

Status
draft
Abstraction
variant
Likelihood
low
C C++

In many languages, the compare statement is very close in appearance to the assignment statement; they are often confused.

Common Consequences

availability integrity
Impacts
unexpected state

Detection Methods

automated static analysis

Potential Mitigations

Phases:
testing
Descriptions:
• Many IDEs and static analysis products will detect this problem.