MISRAC2012-Rule-21.13
In this section:
Synopsis
(Mandatory) The relevant functions from <ctype.h> are defined to take an int argument where the expected value is either in the range of an unsigned char or is a negative value equivalent to EOF. The use of any other values results in undefined behaviour.
Enabled by default
Yes
Severity/Certainty
High/Low

Full description
Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF.
Coding standards
- CERT STR37-C
Arguments to character handling functions must be representable as an unsigned char
- MISRA C:2012 Rule-21.13
(Mandatory) Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF
Code examples
The following code example fails the check and will give a warning:
#include <ctype.h>
#include "mc3_types.h"
bool_t f(uint8_t a) {
return isalpha( 256 );
}
The following code example passes the check and will not give a warning about this issue:
#include <ctype.h>
#include <stdio.h>
#include "mc3_types.h"
bool_t f(uint8_t a) {
return isdigit ( ( int32_t ) a )
&& isalpha ( ( int32_t ) 'b' )
&& islower( EOF );
}