ppc32_exec_DIVW can produce the wrong result in stable
flaviojs opened this issue · 0 comments
flaviojs commented
The issue is already fixed in unstable.
The registers of this operation are supposed to be interpreted as signed numbers.
The temporary variables a
and b
have an unsigned type, which can produce a bad result with negative registers.
Examples:
a | b | unsigned | signed |
---|---|---|---|
-1 | 2 | ((m_uint32_t)-1) / 2 = 2147483647 | -1 / 2 = 0 |
-1 | -2 | ((m_uint32_t)-1) / ((m_uint32_t)-2) = 0 | -1 / -2 = 2 |
1 | -1 | 1 / ((m_uint32_t)-1) = 0 | 1 / -1 = -1 |
Discovered while converting to rust.