Swap args for lhs const overflow check.
authorRobert Bradshaw <robertwb@gmail.com>
Wed, 31 Oct 2012 18:56:16 +0000 (11:56 -0700)
committerRobert Bradshaw <robertwb@gmail.com>
Wed, 31 Oct 2012 18:56:16 +0000 (11:56 -0700)
Cython/Compiler/ExprNodes.py

index 031811f..31de95c 100755 (executable)
@@ -8011,7 +8011,13 @@ class NumBinopNode(BinopNode):
             return
         if self.type.is_complex:
             self.infix = False
-        if self.type.is_int and env.directives['overflowcheck'] and self.operator in self.overflow_op_names:
+        if (self.type.is_int
+                and env.directives['overflowcheck']
+                and self.operator in self.overflow_op_names):
+            if (self.operator in ('+', '*')
+                    and self.operand1.has_constant_result()
+                    and not self.operand2.has_constant_result()):
+                self.operand1, self.operand2 = self.operand2, self.operand1
             self.overflow_check = True
             self.func = self.type.overflow_check_binop(
                 self.overflow_op_names[self.operator],