robertwb / issues-import-test

0 stars 0 forks source link

Invalid C code for pxd-inline function that returns memory view #1013

Open robertwb opened 9 years ago

robertwb commented 9 years ago
# foo.pxd:

from cython cimport numeric
from libc.stdlib cimport malloc
cdef inline numeric[mview(size_t size, numeric* null):
    return <numeric[:size:1](::1])>malloc(size * sizeof(null))

# bar.pyx:

from foo cimport mview
def main():
    return mview(1, <double*>NULL)

C compiler error is:

bar.c: In function ‘__pyx_fuse_0__pyx_f_3foo_mview’:
bar.c:1571:13: error: incompatible types when assigning to type ‘__Pyx_memviewslice’ from type ‘int’
   __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dc_short(((PyObject *)__pyx_t_2));
             ^

Originally reported here:

http://thread.gmane.org/gmane.comp.python.cython.user/13946

Migrated from http://trac.cython.org/ticket/861