MISRA.SIGNED_CHAR.NOT_NUMERIC'signed char' or 'unsigned char' is used for non-numeric value. MISRA-C Rule 6.2 (required): signed and unsigned char type shall be used only for the storage and use of numeric values.There are three distinct char types, (plain) char, signed char and unsigned char. signed char and unsigned char shall be used for numeric data and plain char shall be used for character data. The signedness of the plain char type is implementation defined and should not be relied upon. Character values/data are character constants or string literals such as 'A', '5', '\n', "a". Numeric values/data are numbers such as 0, 5, 23, \x10, -3. Character sets map text characters onto numeric values. Character values are the "text". The permissible operators on plain char types are the simple assignment operator (=), equality operators (==, !=) and explicit casts to integral types. Additionally, the second and third operands of the ternary conditional operator may both be of plain char type. MISRA-C++ Rule 5-0-12 (required): signed char and unsigned char type shall only be used for the storage and use of numeric values.[Implementation 3.9.1(1), 7.1.5.2(1)] RationaleThere are three distinct char types, (plain) char, signed char and unsigned char. signed char and unsigned char shall only be used for numeric data and plain char shall only be used for character data. As it is implementation-defined, the signedness of the plain char type should not be assumed. Note that Rule 3—9—2 also applies, so the 'uint8_t' and 'int8_t' types are covered by this rule. Exampleint8_t a = 'a'; // Non-compliant — explicitly signed uint8_t b = '\r'; // Non-compliant — explicitly unsigned int8_t c = 10; // Compliant uint8_t d = 12U; // Compliant signed char e = 11; // Compliant with this rule, but breaks Rule 3—9—2 External Guidance |