[Cython] Possible bug related to multiple assignment

Stefan Behnel stefan_ml at behnel.de
Thu Jun 16 10:35:13 CEST 2011


Stefan Behnel, 16.06.2011 09:46:
> Andrew Collette, 16.06.2011 04:51:
>> I ran into some odd behavior when working on my cython-based project
>> (h5py). The following cython code snippet is the culprit ("priv" is a
>> function argument of type void**):
>>
>> cdef conv_size_t *sizes
>> priv[0] = sizes =<conv_size_t*>malloc(sizeof(conv_size_t))
>>
>> gets turned into this (with Cython 0.14.1):
>>
>> (__pyx_v_priv[0]) = ((__pyx_t_4h5py_5_conv_conv_size_t
>> *)malloc((sizeof(__pyx_t_4h5py_5_conv_conv_size_t))));
>> __pyx_v_sizes = ((__pyx_t_4h5py_5_conv_conv_size_t
>> *)malloc((sizeof(__pyx_t_4h5py_5_conv_conv_size_t))));
>
> This is fixed in the latest master branch.

Ah, sorry. It was actually broken, even though my test run initially told 
me otherwise. Strange ...

The problem was the C type cast, which was incorrectly considered a 
"simple" expression that didn't need a temporary assignment. Malloc is the 
most obvious case where this hits, as it's almost always used through a cast.

It's fixed now. Thanks for report and example.

Stefan


More information about the cython-devel mailing list