CWE-563

Assignment to Variable without Use. [Bad-Coding-Practices, Improper-Adherence-To-Coding-Standards]

Required inputs: IR, StaticSemanticAnalysis

The variable's value is assigned but never used, making it a dead store. After the assignment, the variable is either assigned another value or goes out of scope. It is likely that the variable is simply vestigial, but it is also possible that the unused variable points out a bug.
Demonstrative Examples
Example 1

The following code excerpt assigns to the variable r and then overwrites the value without using it.

Example Language:C
    r = getName();
    r = getNewBuffer(buf);
Excerpts from CWE [https://cwe.mitre.org], Copyright (C) 2006-2026, the MITRE Corporation. See section 9.4. "3rd-Party Licenses" in the documentation for full details.

Possible Messages

Key

Text

Severity

Disabled

conditional_unused_def

Result of assignment is not used along some path(s)

None

True

init_used_in_other_isr

Initialization is not used except within code reached from an entry point that might be triggered by an interrupt

None

True

unused_catch_parameter

Unused implicit initialization of catch clause parameter (you can use an unnamed one instead)

None

False

unused_def

Result of assignment is not used

None

False

unused_init

Unused initialization

None

False

used_in_other_isr

Result of assignment is not used except within code reached from an entry point that might be triggered by an interrupt

None

True

Options

report_dead_initializations

report_dead_initializations : bool = True

Whether initializations may be reported as dead.