diff options
author | Peter Wu <lekensteyn@gmail.com> | 2011-11-29 11:49:26 +0000 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2011-11-29 11:49:26 +0000 |
commit | eabfc84fac0e42635cccabf5c8f883585da60de8 (patch) | |
tree | 15005a40fdcc49089d69ea1fafb7b310f5e350d5 /pp2cc.py | |
parent | 90ec610f709dc7cb25bbb3c288ec3e80ae0bc97e (diff) | |
download | pp2cc-eabfc84fac0e42635cccabf5c8f883585da60de8.tar.gz |
Fix value for substraction in constant expressions
Diffstat (limited to 'pp2cc.py')
-rwxr-xr-x | pp2cc.py | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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 |