04-04-2017, 02:59 PM
My static analyzer is throwing the following warning:
I think this warning may be a false positive because, despite the 32U having a uint8_t underlying type, the expression should take the underlying type of the larger type, in this case the uint32_t, thus making the need for the static_cast unnecessary.
Do you agree this is a false positive? Or am I looking at it all wrong?
Quote:MCPP Rule 5-0-3: This complex expression is implicitly converted to a different essential typefor the following code:
Code:
void func(const uint32_t arg)
{
//32U has underlying type uint8_t
const uint32_t u32a = arg % 32U; //warning issued in this line
const uint32_t u32b = static_cast(arg % 32U); //compliant
}
Do you agree this is a false positive? Or am I looking at it all wrong?
<t></t>