...
When the block is small, the danger of reusing variable names is mitigated by the visibility of the immediate declaration. Even in this case, however, variable name reuse is not desirable. In general, the larger the declarative region of an identifier, the more descriptive and verbose should be the name of the identifier.
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL00DCL01-PL | lowLow | probableProbable | mediumMedium | P2P4 | L3 |
...
CERT C++ Secure Coding Standard: DCL01-CPP. Do not reuse variable names in subscopes
CERT C Secure Coding Standard: DCL01-C. Do not reuse variable names in subscopes
Automated Detection
Tool | Version | Checker | Description | |||
---|---|---|---|---|---|---|
B::Lint | 5.0 | .* masks earlier declaration in same scope | Implemented | Perl::Critic | 5.0 | Modules_ProhibitEvilModules | Implemented
Related Guidelines
SEI CERT C Coding Standard | DCL01-C. Do not reuse variable names in subscopesSEI CERT C++ Coding Standard |
---|---|
SEI CERT C++ Coding Standard | VOID DCL01-CPP. Do not reuse variable names in subscopes |
Bibliography
...