A dead store happens when a local variable is assigned a value that is not read by any subsequent instruction. Calculating or retrieving a value only to then overwrite it or throw it away, could indicate a serious error in the code. Even if it's not an error, it is at best a waste of resources. Therefore all calculated values should be used.

## Noncompliant Code Example

    function pow(a, b) {
      if(b == 0) {
        return 0;
      }
      var x = a;
      for(var i = 1, i < b, i++) {
        x = x * a;  //Dead store because the last return statement should return x instead of returning a
      }
      return a;
    }

## Compliant Solution

    function pow(a, b) {
      if(b == 0) {
        return 0;
      }
      var x = a;
      for(var i = 1, i < b, i++) {
        x = x * a;
      }
      return x;
    }

## See

- MITRE, CWE-563 - Assignment to Variable without Use ('Unused Variable')
- CERT, MSC13-C - Detect and remove unused values
- CERT, MSC13-CPP - Detect and remove unused values