For portable applications, use only the assignment =
operator, the equality operators ==
and !=
, and the unary &
operator on plain character or plain wide character-typed expressions.
This is recommended because the C99 standard requires only the digit characters ('0' - '9') to have consecutive numerical values \[[C99 N1401]\]. Thus, operations that rely on expected values for plain character or plain wide character-typed expressions can lead to unexpected behavior. Wiki Markup
However, because of the requirement for digit characters, other operators can be used for them according to the following restrictions:
...
Character types should be chosen and used in accordance with guideline STR04-C. Use plain char for characters in the basic character set.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
STR09-C | low | unlikely | low | P3 | L3 |
Other Languages
Related Guidelines
C++ Secure Coding Standard This rule appears in the C+\+ Secure Coding Standard as \[[cplusplus: STR07-CPP. Don't assume numeric values for expressions with type plain character]\]. Wiki Markup
Bibliography
Wiki Markup |
---|
\[[C99 N1401]\] Section 5.2.1 "Character sets" |
...