robertwb / issues-import-test

0 stars 0 forks source link

Illegal C code generated with numpy complex type #1030

Open robertwb opened 8 years ago

robertwb commented 8 years ago

The Cython module

cimport numpy as np

cdef np.float64_t x
cdef np.complex128_t y

cdef foo(self):
    return x / y

gives compiler warnings

...: implicit declaration of function ‘fabs_npy_float64’ [        } else if (fabs_npy_float64(b.real) >= fabs_npy_float64(b.imag)) {
         ^
...: implicit declaration of function ‘hypot_npy_float64’ [-Wimplicit-function-declaration](-Wimplicit-function-declaration]
)
             return hypot_npy_float64(z.real, z.imag);
             ^
...: implicit declaration of function ‘atan2_npy_float64’ [                theta = atan2_npy_float64(a.imag, a.real);
                 ^
...: implicit declaration of function ‘log_npy_float64’ [-Wimplicit-function-declaration](-Wimplicit-function-declaration]
)
             lnr = log_npy_float64(r);
             ^
...: implicit declaration of function ‘exp_npy_float64’ [            z_r = exp_npy_float64(lnr * b.real - theta * b.imag);
             ^
...: implicit declaration of function ‘cos_npy_float64’ [-Wimplicit-function-declaration](-Wimplicit-function-declaration]
)
             z.real = z_r * cos_npy_float64(z_theta);
             ^
...: implicit declaration of function ‘sin_npy_float64’ [-Wimplicit-function-declaration]
             z.imag = z_r * sin_npy_float64(z_theta);
             ^

and an error when imported:

ImportError: .../cybug.so: undefined symbol: fabs_npy_float64

The import error is a regression since Cython 0.24, the compiler warnings are also in the released Cython 0.24.

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

robertwb commented 8 years ago

@jdemeyer changed Compiling this as C++ code works around the problem.