MISRAC++2008-4-5-3
In this section:
Synopsis
(Required) Expressions with type (plain) char and wchar_t shall not be used as operands to built-in operators other than the assignment operator =, the equality operators == and !=, and the unary & operator.
Enabled by default
Yes
Severity/Certainty
Low/High

Full description
Arithmetic is performed on objects of type plain char, without an explicit signed or unsigned qualifier. This check is identical to MISRAC2004-6.1.
Coding standards
- CERT INT07-C
Use only explicitly signed or unsigned char type for numeric values
- MISRA C:2004 6.1
(Required) The plain char type shall be used only for the storage and use of character values.
Code examples
The following code example fails the check and will give a warning:
typedef signed char INT8;
typedef unsigned char UINT8;
UINT8 toascii(INT8 c)
{
return (UINT8)c & 0x7f;
}
int func(int x)
{
char sc = 4;
char *scp = ≻
UINT8 (*fp)(INT8 c) = &toascii;
x = x + sc;
x *= *scp;
return (*fp)(x);
}
The following code example passes the check and will not give a warning about this issue:
typedef signed char INT8;
typedef unsigned char UINT8;
UINT8 toascii(INT8 c)
{
return (UINT8)c & 0x7f;
}
int func(int x)
{
signed char sc = 4;
signed char *scp = ≻
UINT8 (*fp)(INT8 c) = &toascii;
x = x + sc;
x *= *scp;
return (*fp)(x);
}