Versions Compared

Key

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

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.

Wiki MarkupThis 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.

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 Wiki MarkupThis rule appears in the C+\+ Secure Coding Standard as \[[cplusplus: STR07-CPP. Don't assume numeric values for expressions with type plain character]\].

Bibliography

Wiki Markup
\[[C99 N1401]\] Section 5.2.1 "Character sets"

...