7 Jun 2012 10:44
[Cython] Bug: bad C code generated for (some) "... and ... or ..." expressions
"cython 0.13" generates bad C code for the attached "pyx" file.
"cython" itself recognizes that it did something wrong and emits "<error>;"
to the generated file:
...
static __pyx_t_12cybug_and_or_pointer __pyx_f_12cybug_and_or_bug(PyObject *__pyx_v_o) {
__pyx_t_12cybug_and_or_pointer __pyx_r;
int __pyx_t_1;
__pyx_t_12cybug_and_or_pointer __pyx_t_2;
<error>;
<error>;
...
The error probably happens because it is difficult for "cython" to determine the type for "and" and "or" expressions (if the operand types differ). In an "cond and t or f" expression, however, the result type is "type(t)" if "type(t) == type(f)", independent of "type(cond)". It might not be worse to special case this type of expressions. It would however be more friendly to output an instructive error message instead of generating bad C code. -- Dieter(Continue reading)
RSS Feed