Parameter hidden by local variable

The CWARN.HIDDEN.PARAM checker finds instances in which a local variable hides a parameter.

Vulnerability and risk

Since a program will always use the variable closest in scope, local variables can hide the parameters of their containing functions and make those parameters unreachable. When this unintended behavior occurs, the consequences can be unexpected.

Vulnerable code example

  void foo(int a) {
    int a = 0;     
         if (a > 3) {...}

In this example, Klocwork flags line 2 to indicate that local variable 'a' is hiding the function parameter.