MISRA C++:2008 Rule 2-10-1
Different identifiers shall be typographically unambiguous
Description
Rule Definition
Different identifiers shall be typographically unambiguous.1
Rationale
When you use different identifiers that look typographically similar, you might inadvertently use the incorrect identifier later in your code. Such typographically ambiguous identifiers might lead to bugs that are difficult to diagnose.
Use identifiers that are unambiguously distinct. Avoid using identifiers that differ by a combination of these:
The use of a lowercase letter instead of an uppercase one, and vice versa.
The presence or absence of the underscore character.
The interchange of the letter
O
and the digit0
.The interchange of the letter
I
and the digit1
.The interchange of the letter
I
and the letterl
.The interchange of the letter
S
and the digit5
.The interchange of the letter
Z
and the digit2
.The interchange of the letter
n
and the letterh
.The interchange of the letter
B
and the digit8
.The interchange of the letters
rn
and the letterm
.
Polyspace Implementation
Polyspace® reports a defect if two identifiers differ by a combination of ambiguous characters mentioned in the preceding list. The rule checker does not consider the fully qualified names of variables when checking this rule.
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: Required |
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.