From 348974c84401eccb35020c5ecec61d4863070004 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 22 Sep 2010 01:40:45 -0700 Subject: [PATCH] Fix pow(float, -) for MSVC. --- Cython/Compiler/ExprNodes.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index fd30a8dd..073d7ddc 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -5658,7 +5658,7 @@ class PowNode(NumBinopNode): error(self.pos, "complex powers not yet supported") self.pow_func = "" elif self.type.is_float: - self.pow_func = "pow" + self.pow_func = "pow" + self.type.math_h_modifier else: self.pow_func = "__Pyx_pow_%s" % self.type.declaration_code('').replace(' ', '_') env.use_utility_code( @@ -5666,10 +5666,16 @@ class PowNode(NumBinopNode): type=self.type.declaration_code(''))) def calculate_result_code(self): + # Work around MSVC overloading ambiguity. + def typecast(operand): + if self.type == operand.type: + return operand.result() + else: + return self.type.cast_code(operand.result()) return "%s(%s, %s)" % ( self.pow_func, - self.operand1.result(), - self.operand2.result()) + typecast(self.operand1), + typecast(self.operand2)) # Note: This class is temporarily "shut down" into an ineffective temp -- 2.26.2