From d002e2b651f0823b1f255f6e00441063a50a849f Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 31 Oct 2012 11:56:16 -0700 Subject: [PATCH] Swap args for lhs const overflow check. --- Cython/Compiler/ExprNodes.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 031811f..31de95c 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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], -- 2.7.4