Here is a sample function in question:
def first_or_last(int[:] values, bint first):
cdef Py_ssize_t i
if first:
i = -1
yield values[i]
else:
i = 0
yield values[i]
In both cases, i should always be initialized when used, but gcc emits something along the lines of
hello.c: In function ‘__pyx_gb_5hello_2generator’:
hello.c:2326:32: warning: ‘__pyx_t_2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
__pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
Moving the yields outside of the branches works fine, but this is a problem showing up in a larger function where I don't know that that is possible
I've attached the generated code. I think this is an issue where the generator saving the state of the function but not entirely sure
hello.c.zip
Here is a sample function in question:
In both cases,
ishould always be initialized when used, but gcc emits something along the lines ofMoving the yields outside of the branches works fine, but this is a problem showing up in a larger function where I don't know that that is possible
I've attached the generated code. I think this is an issue where the generator saving the state of the function but not entirely sure
hello.c.zip