Question
Passing a function argument of the wrong type is allowed by MISRA?
I'm working on a bare-metal software on STM32H7 which is controled by a coding rules analyser (HELIX QAC) following MISRA-C 2012 standard.
The use case is the following:
void function1(unsigned int i)
{
...
}
void function2(void)
{
...
function1(1);
}
The call to function1 is done with a signed integer but apparently there is no MISRA rule to forbid that. I know conversion from signed to unsigned is perfectly defined in C but it's still surprising because usually MISRA is very strict regarding implicit conversion (even if well defined in the C standard).
For example the following (not really a conversion by the way) returns an error:
unsigned long l = 0xFFFFFFFF;
because there is no U
prefix (or explicit cast).
Is there a reason for that / a specificity in the C standard regarding function parameter implicit conversion ?