summaryrefslogtreecommitdiff
path: root/pp2cc.py
diff options
context:
space:
mode:
Diffstat (limited to 'pp2cc.py')
-rwxr-xr-xpp2cc.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/pp2cc.py b/pp2cc.py
index ecd73a8..a1d1bbd 100755
--- a/pp2cc.py
+++ b/pp2cc.py
@@ -1112,6 +1112,10 @@ class Parse(object):
else:
operand1 = self.determineConstValue(node.left)
operand2 = self.determineConstValue(node.right)
+ if op == "-":
+ # ensure that the result of substraction is positive by
+ # setting the (WORDSIZE+1)-nth bit on the first operand
+ operand1 |= pow(2, self.WORDSIZE)
if op in ("<", ">", "<=", ">="):
value = int(getattr(operator, op)(operand1, operand2))
# 0 < 1 and -2 < -1 holds, but -1 < 0 does not. If the sign