Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
char ch = 'b';
if ( ( ch >= 'a' ) && (ch <= 'c')) ){
  /* ... */
}

Compliant Solution

In this example, the specific check is enforced using compliant operations on character expressions.

Code Block
bgColor#CCCCFF
char ch = 't';
if ( ( ch == 'a' ) || ( ch == 'b') || ( ch == 'c')) ){
  /* ... */
}

Exceptions

STR09-EX1: It is ok to assume consecutive value for characters like a~z on platforms where ASCII or Unicode is used. This rule is to raise awareness of platform portability, such as if the code is migrated from ASCII systems to non-ASII systems.

...