Commit d81d4326 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix C++ division when true division is enabled.

This fixes Github issue #1950.
parent 5a8c077a
......@@ -11532,7 +11532,7 @@ class DivNode(NumBinopNode):
self.operand2 = self.operand2.coerce_to_simple(env)
def compute_c_result_type(self, type1, type2):
if self.operator == '/' and self.ctruedivision:
if self.operator == '/' and self.ctruedivision and not self.is_cpp_operation():
if not type1.is_float and not type2.is_float:
widest_type = PyrexTypes.widest_numeric_type(type1, PyrexTypes.c_double_type)
widest_type = PyrexTypes.widest_numeric_type(type2, widest_type)
......@@ -11623,7 +11623,7 @@ class DivNode(NumBinopNode):
code.putln("}")
def calculate_result_code(self):
if self.type.is_complex:
if self.type.is_complex or self.is_cpp_operation():
return NumBinopNode.calculate_result_code(self)
elif self.type.is_float and self.operator == '//':
return "floor(%s / %s)" % (
......
# mode: run
# tag: cpp, werror
from __future__ import division
from cython cimport typeof
cimport cython.operator
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment