diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 02087e22ec820d71422182c1abeaa2fedb8758a0..e08574207ebcc7174b915f01918bac7f8393006b 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -4338,6 +4338,10 @@ def widest_numeric_type(type1, type2): type1 = type1.ref_base_type if type2.is_reference: type2 = type2.ref_base_type + if type1.is_const: + type1 = type1.const_base_type + if type2.is_const: + type2 = type2.const_base_type if type1 == type2: widest_type = type1 elif type1.is_complex or type2.is_complex: diff --git a/tests/run/cdivision_CEP_516.pyx b/tests/run/cdivision_CEP_516.pyx index c3ad2ecf8f109a995aef831a27aed264229e1f22..c8b24a0e1bc79b925521466d5847ae75678f8bc4 100644 --- a/tests/run/cdivision_CEP_516.pyx +++ b/tests/run/cdivision_CEP_516.pyx @@ -191,3 +191,14 @@ def py_div_long(long a, long b): OverflowError: ... """ return a / b + +def c_div_const_test(a, b): + """ + >>> c_div_const_test(5, 3) + 1 + """ + return c_div_const(a, b) + +cdef long c_div_const(const long a, int b): + cdef long c = a / b + return c