AUTOSAR C++14 Rule A21-8-1

Arguments to character-handling functions shall be representable as an unsigned char

Description

Rule Definition

Arguments to character-handling functions shall be representable as an unsigned char.

Rationale

You cannot use plain char variables as arguments to character-handling functions declared in <cctype>, for instance, isalpha() or isdigit(). On certain platforms, plain char variables can have negative values that cannot be represented as unsigned char or EOF, resulting in undefined behavior.

Polyspace Implementation

The check raises a flag when you use a signed or plain char variable with a negative value as argument to a character-handling function.

Troubleshooting

If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.

Check Information

Group: Strings library
Category: Required, Automated
Introduced in R2019a