02-02-2010, 12:23 PM
Thanks for the rely!
I just realized that I forgot to describe the background for the question. The company I represent develops compilers with a built-in Misra C checker. (I'm fully aware that you have to break a number of Misra rules to use plain char:s when performing arithmetical operations, still code like that is used.)
Concretely, in the following program, our tools currently issues a violation for rule 10.3 for both functions, but only the first is considered a violation to rule 10.5. However, the problem that the rule tries to catch is the same for both functions.
typedef unsigned short UINT16_T;
typedef unsigned char UINT8_T;
typedef char CHAR_T;
UINT16_T from_unsigned_char(UINT8_T a);
UINT16_T from_plain_char(CHAR_T a);
UINT16_T from_unsigned_char(UINT8_T a)
{
return ~a;
}
UINT16_T from_plain_char(CHAR_T a)
{
return ~a;
}
So the question still stands: Should/could we issue a Misra C violation for rule 10.5?
-- Anders
I just realized that I forgot to describe the background for the question. The company I represent develops compilers with a built-in Misra C checker. (I'm fully aware that you have to break a number of Misra rules to use plain char:s when performing arithmetical operations, still code like that is used.)
Concretely, in the following program, our tools currently issues a violation for rule 10.3 for both functions, but only the first is considered a violation to rule 10.5. However, the problem that the rule tries to catch is the same for both functions.
typedef unsigned short UINT16_T;
typedef unsigned char UINT8_T;
typedef char CHAR_T;
UINT16_T from_unsigned_char(UINT8_T a);
UINT16_T from_plain_char(CHAR_T a);
UINT16_T from_unsigned_char(UINT8_T a)
{
return ~a;
}
UINT16_T from_plain_char(CHAR_T a)
{
return ~a;
}
So the question still stands: Should/could we issue a Misra C violation for rule 10.5?
-- Anders
<t></t>