From: Robert Bradshaw Date: Wed, 22 Sep 2010 08:40:45 +0000 (-0700) Subject: Fix pow(float, -) for MSVC. X-Git-Tag: 0.14.alpha0~309 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=348974c84401eccb35020c5ecec61d4863070004;p=cython.git Fix pow(float, -) for MSVC. --- 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