Your code includes a dead store, where a variable is assigned a value but never used afterward. Dead stores can clutter the codebase and obscure the program's logic, leading to potential inefficiencies. Consider removing the assignment or re-evaluating the variable's usage to ensure optimal code organization and performance. Identifying and eliminating dead stores improves code readability and maintainability.
1#include <stdio.h>
2
3int unusedAssignedVariablesNonCompliant(int y) {
4 int x = 0;
5 // Noncompliant: dead store
6 x = 100;
7 x = 200;
8 return x + y;
9}
1#include <stdio.h>
2
3int unusedAssignedVariablesCompliant(int y) {
4 // Compliant: no unnecessary assignment
5 int x = 200;
6 return x + y;
7}