[Cython] 'local variable referenced before assignment' warnings

Robert Bradshaw robertwb at math.washington.edu
Wed Sep 21 09:49:43 CEST 2011

On Wed, Sep 21, 2011 at 12:32 AM,  <robert.rex at exasol.com> wrote:
> Hi,
> I got a (misleading) Cython warning from the following code example:
> --------------------------------
> cdef extern from "<bar.h>":
>    void foo(int &a, int &b)
> cdef cyfoo():
>    cdef int cya, cyb
>    foo(cya, cyb)
> --------------------------------
> Executing "cython --cplus" produced these messages:
> --------------------------------
> warning: example.pyx:6:11: local variable 'cya' referenced before assignment
> warning: example.pyx:6:16: local variable 'cyb' referenced before assignment
> --------------------------------
> This started with Cython 0.15 (and 0.15.1 also issues these warnings).
> I assume this warning shouldn't be produced (as in a similar issue
> here: http://trac.cython.org/cython_trac/ticket/714), right?!

The warning seem correct to me, or is foo actually modifying the
values of cya and cyb? (I suppose this could be possible by taking the
address of the "passed by reference" arguments, but would seem like a
*very* poor API design.)

- Robert

More information about the cython-devel mailing list