...
Reusing a variable name in a subscope can lead to unintentionally referencing an incorrect variable.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
DCL01-C | Low | Unlikely | Medium | P2 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||
|---|---|---|---|---|---|---|---|
| Astrée |
|
| Supported, but no explicit checker | |||||||||
| CodeSonar |
| LANG.ID.ND.NEST | Non-distinct identifiers: nested scope | ||||||
| Compass/ROSE |
| CC2.DCL01 | Fully implemented | |||||||
| Klocwork |
|
| LDRA tool suite |
| 131 S | Fully implemented | ||||||
| Parasoft C/C++test |
|
|
| MISRA2004-5_2_{a,b} | Fully implemented | |||||||
| Polyspace Bug Finder | R2016a | Variable shadowing | Variable hides another variable of same name with nested scope | ||||||
| PRQA QA-C |
| 2547 | Fully implemented | ||||||
| Splint |
|
| PVS-Studio | 6.22 | V561, V688, V703, V711 | General analysis rule set |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
| SEI CERT C++ Coding Standard | VOID DCL01-CPP. Do not reuse variable names in subscopes |
| MISRA C:2012 | Rule 5.3 (required) |
...
...