Closed kquick closed 4 years ago
The relevant code appears to be in What4.Expr.Builder:
bvAshr sym x y
| Just i <- asSignedBV x, Just n <- asSignedBV y = do
bvLit sym (bvWidth x) $ Bits.shiftR i (fromIntegral n)
| Just 0 <- asUnsignedBV y = do
pure x
| otherwise = do
sbMakeExpr sym $ BVAshr (bvWidth x) x y
In the first clause, the shift amount n
should be treated as unsigned. And, as with #432, there should be tests for shifting more than bvWidth
.
Fixed by #450
Currently, the
bvAshr
shift value is treated as a signed value, resulting in a shift left if the shift value is negative.From SMTLib theory:
[space added after the # character above because of github issue/pr completion]
This indicates that the shift amount for
bvAshr
should changed to always be treated as unsigned, which matches the handling ofbvLshr
andbvShl
as well as thebvRor
andbvRol
operations.