MISRA C++:2008 Rule 2-10-5
The identifier name of a non-member object or function with static storage duration should not be reused
Description
Rule Definition
The identifier name of a non-member object or function with static storage duration should not be reused.1
Rationale
Reusing the name of an identifier with static storage duration makes the code confusing and difficult to maintain. You might use the wrong identifier in your code and introduce bugs that are difficult to fix.
The rule applies even if the identifiers belong to different namespaces because the reuse leaves the chance that you mistake one identifier for the other.
Polyspace Implementation
The rule flags situations where the name of an identifier with static storage duration is reused. The rule checker flags redefined functions only when there is a declaration.
The checker is not raised on unused code such as
- Noninstantiated templates 
- Uncalled - staticor- externfunctions
- Uncalled and undefined local functions 
- Unused types and variables 
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group: Lexical Conventions | 
| Category: Advisory | 
Version History
Introduced in R2013b1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder documentation are from the following MISRA standards:
- MISRA C:2004 
- MISRA C:2012 
- MISRA C:2023 
- MISRA C++:2008 
- MISRA C++:2023 
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.