CWE-481β€”Assigning instead of Comparing

PUBLISHEDweakness recordLow
released 2006-07-19 Β· last modified 2026-04-30

Metadata

CWE ID:
CWE-481
Abstraction:
Variant
Structure:
Simple
Status:
Draft
Release Date:
2006-07-19
Latest Modification Date:
2026-04-30

Weakness Name

Assigning instead of Comparing

Description

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

In many languages the compare statement is very close in appearance to the assignment statement and are often confused. This bug is generally the result of a typo and usually causes obvious problems with program execution. If the comparison is in an if statement, the if statement will usually evaluate the value of the right-hand side of the predicate.

Common Consequences

Scope:
Other
Impact:
Alter Execution Logic

Related Weaknesses