Somewhere in my project I have this code:
{
uint8_t u8Integer = 0xFFU;
returnCode = someFucntion(&u8Integer);
uint8_t u8Decimal = 0xFFU;
returnCode = someOtherFucntion(&u8Decimal);
uint16_t u16Temp = ((static_cast<uint16_t>(u8Integer) << 8U) | static_cast<uint16_t>(u8Decimal));
if(u16Temp <= 0xC000) // Problem here
{
// Uneracahble Code ?
}
else // {...}
}
An automatic MISRA static check throws an error saying that the if
statement is never true. I guess Is because the u8Decimal
and u8Integer
are modified when passing their pointers to someFucntion
and someOtherFucntion
and the checker assumes they are still 0xFF
and therefore u16Temp
will never change making it alwas > 0xC000
.
When I run this program, the values of u16Temp
change properly (sometimes entering the if
statement and nometimes not).
the checker says "The inferred value of u16Temp is 65535"
Is this just a case where the checker is not working perfectly? Or do I actually have a code problem?
I tried setting the variables as volatile
but this didn't work.
Aucun commentaire:
Enregistrer un commentaire