07-06-2011, 08:02 AM
Hi everyone!
I have a question about rule 10.1 and 10.2
Whenever I try to work with an if or while and use two comparions which are logically connected I get an MISRA issue when the two comparisons have different data types.
e.g. int16 and int32
Because the results of the two comparions is somehow boolean I would not expected to get:
The value of an expression implicitly converted to a different type.
Is it really an issue? I know I can cast both to the same data type but it looks strange.
Example:
I have a question about rule 10.1 and 10.2
Whenever I try to work with an if or while and use two comparions which are logically connected I get an MISRA issue when the two comparisons have different data types.
e.g. int16 and int32
Because the results of the two comparions is somehow boolean I would not expected to get:
The value of an expression implicitly converted to a different type.
Is it really an issue? I know I can cast both to the same data type but it looks strange.
Example:
Code:
t_int8 a = 3;
t_uint16 b = 7;
if ((a > 3) && (b > 5u))
{
a++;
}
<t></t>