Why is type conversion int32_t to uint32_t a Sign Change Integer Conversion Overflow Defect in Polyspace?
Show older comments
Code generated for a division operation with 'Floor' rounding and 'int32' output datatype is generating a Polyspace Defect: 'Sign Change Integer Conversion Overflow'. The supposed overflow occurs in the code where the absoute value of the numerator is calculated. When the numerator is negative, the value is cast as an uint32_T before calculating the two's complement to make it positive. I don't understand how this can overflow. Is this a bug with Polyspace?
Example:
int32_T div_s32_floor(int32_T numerator, etc ...)
{
uint32_T absNum;
...
absNum = (numerator < 0) ? ((~((uint32_T)numerator)) + 1U): ((uint32_T)numerator);
...
}
/* function call */
div_s32_floor(int32_t numerator, etc...);
Accepted Answer
More Answers (0)
Categories
Find more on Troubleshoot Compilation Errors in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!