MISRA Discussion Forums
10.1 Non-constant value to function - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.10 Arithmetic Type Conversions (https://forum.misra.org.uk/forumdisplay.php?fid=37)
+---- Thread: 10.1 Non-constant value to function (/showthread.php?tid=924)



10.1 Non-constant value to function - borth - 26-11-2012

Hey,

i have a problem with these 10.1 Rule:

Code:
void foo_bar(uint32_t u32)      /* another function to do something */

void test_func(uint8_t u8)
{
   uint32_t u32Convert = (uint32_t)u8;
   ...
   foo_bar(u32Convert);      /*Error - Note 960 Violates MISRA 2004 Required Rule 10.1, Prohibited Implicit Conversion: Non-constant argument to function */
   ...
}
MISRA says that a expression, which is a function argument, shouldn't be converted to a underlying type.
But i took a 8 bit value, expand to 32bit and use this for the function. The type of u32Convert is uint32_t as it should be for the function argument of foo_bar.
Is it neccessary to know what foo_bar does with the value?

Thanks for your help!
Greetz,


Re: 10.1 Non-constant value to function - misra-c - 30-11-2012

There is no implicit conversion taking place on the function call. The argument u32Convert has type uint32_t and the function prototype on the first line (which is missing a semi-colon) declares the parameter u32 also to have type uint32_t.

It appears that your tool is incorrectly diagnosing a violation of Rule 10.1