Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Do not use the same variable name in two scopes where one scope is contained in another. For example,

  • No other variable should share the name of a global variable if the other variable is in a subscope of the global variable.
  • A block should not declare a variable with the same name as a variable declared in any block that contains it.

...

Tool

Version

Checker

Description

Section

LDRA tool suite

Include Page
c:LDRA_V
c:LDRA_V

 

 

Section

Splint

Include Page
c:Splint_V
c:Splint_V

 

 

Section

Compass/ROSE

 

 

 

Section

Klocwork

Include Page
c:Klocwork_V
c:Klocwork_V
Section

IF_MULTI_DECL
IF_MULTI_DEF
IF_MULTI_KIND

 

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...

Related Guidelines

CERT C++ Secure Coding Standard: DCL01-CPP. Do not reuse variable names in subscopes

Java The CERT Oracle Secure Coding Standard for Java: SCP02-J. Do not reuse names

...

Wiki Markup\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 5.2.4.1, "Translation limits" \[[MISRA 2004|AA. Bibliography#MISRA 04]\] Rule

MISRA Rule 5.2

Bibliography

...

      02. Declarations and Initialization (DCL)