[Cython] vtables: bad code generation, incorrect casts.

Stefan Behnel stefan_ml at behnel.de
Wed Jul 30 22:39:25 CEST 2008


Hi,

Dag Sverre Seljebotn wrote:
> Lisandro Dalcin wrote:
>> Brian Granger posted some days ago about problems with multiple inheritance:
>>
>> http://codespeak.net/pipermail/cython-dev/2008-July/001814.html
>>
>> It seems that Cython is generating bad code. A C compiler (gcc) just
>> warn about it, but a C++ compiler (g++)
>> generates an error.
>>
>> A tentative patch for this issue is posted here:
>>
>> http://codespeak.net/pipermail/cython-dev/2008-July/001835.html

The original patch made a test case fail, the attached patch works better (not
sure why this is required, though).


> Even with the patch, the end-result seems a bit strange:
> 
> static PyObject *__pyx_tp_new_4vtab_Bam(PyTypeObject *t, PyObject *a, 
> PyObject *k) {
>    struct __pyx_obj_4vtab_Bam *p;
>    PyObject *o = __pyx_tp_new_4vtab_Foo(t, a, k);
>    if (!o) return 0;
>    p = ((struct __pyx_obj_4vtab_Bam *)o);
>    p->__pyx_base.__pyx_base.__pyx_vtab = (struct 
> __pyx_vtabstruct_4vtab_Foo*)__pyx_vtabptr_4vtab_Bam;
>    return o;
> }
> 
> I.e. on vtable generation it seems to skip its immediate ancestor.

It still seems to be the right thing to do. Maybe Greg can enlighten us here.

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: baseclass-vtab.patch
Type: text/x-patch
Size: 880 bytes
Desc: not available
Url : http://codespeak.net/pipermail/cython-dev/attachments/20080730/1b00450a/attachment.bin 


More information about the Cython-dev mailing list