[Python-apps-team] Bug#607112: fixed upstream
Stefan Behnel
stefan_ml at behnel.de
Thu Dec 30 18:06:52 UTC 2010
Jakub Wilk, 30.12.2010 18:09:
> * Stefan Behnel, 2010-12-30, 08:37:
>> Works for me in 0.14.
>
> Hmm, I just tested 0.14 and I get the very same warning.
:o) right, "$(python3-config --cflags)" actually includes
"-fno-strict-aliasing" on my side. Forgot to check that.
> The code in question (generated by Cython 0.14) is:
>
> | static struct __pyx_vtabstruct_4eggs_Eggs *__pyx_vtabptr_4eggs_Eggs;
> |
> | [...]
> | | static int __Pyx_GetVtable(PyObject *dict, void *vtabptr) {
> | [...]
> | #if PY_VERSION_HEX >= 0x02070000 &&
> !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
> | *(void **)vtabptr = PyCapsule_GetPointer(ob, 0);
> | #else
> | *(void **)vtabptr = PyCObject_AsVoidPtr(ob);
> | #endif
> | [...]
> | }
> | | [...]
> | | if (__Pyx_GetVtable(__pyx_ptype_4eggs_Eggs->tp_dict,
> &__pyx_vtabptr_4eggs_Eggs) < 0) [...]
>
> So a (struct __pyx_vtabstruct_4eggs_Eggs **) is casted to (void *), then
> casted to (void **), and then dereferenced. This indeed violates C aliasing
> rules.
Yes, that looks evil. What seems to work for me, though, is to return the
void* and to cast it appropriately after calling __Pyx_GetVtable(). I think
that's the right way to do it.
Stefan
More information about the Python-apps-team
mailing list