[Cython] Minor code generation problem

Stefan Behnel stefan_ml at behnel.de
Fri Oct 31 09:22:18 CET 2008


Jason Evans wrote:
> Using the latest cython-dev, the following program causes a C compiler
> warning:
>
> ---------------------------------------------------------------------
> cdef foo():
>      cdef x = 42
>
>      if x == 42 and x == 43:
>          print "foo"
>
> foo()
> ---------------------------------------------------------------------
> foo.c: In function ‘__pyx_f_3foo_foo’:
> foo.c:214: warning: unused variable ‘__pyx_3’

I've seen things like this happen when the switch transform optimisation
hits. It can leave already allocated temp variables unused.

Does anyone know if there is an easy way to move the temp allocation to a
later time in cases like this? It would be best to move it after the tree
optimisation transformations.

Stefan



More information about the Cython-dev mailing list