[Pyrex] [Cython] Type casting issues and strict aliasing
Stefan Behnel
stefan_ml at behnel.de
Thu Jun 12 21:39:49 CEST 2008
Hi,
regarding the second issue below, a simple cast to a (void*) works for me:
__pyx_vtable_7r_jiba1_Norwegian.__pyx_base.describe =
(void*)__pyx_f_7r_jiba1_9Norwegian_describe;
Again, this is with gcc 4.1 and Py3.0 SVN. Are there any comments on this one?
What would other compilers say about this?
Stefan
Stefan Behnel wrote:
> Similar things happen when the C methods are initialised in the module init
> function. Currently, we have:
>
> *(void(**)(void))&__pyx_vtable_7r_jiba1_Parrot.describe =
> (void(*)(void))__pyx_f_7r_jiba1_6Parrot_describe;
> *(void(**)(void))&__pyx_vtable_7r_jiba1_Norwegian.__pyx_base.describe =
> (void(*)(void))__pyx_f_7r_jiba1_9Norwegian_describe;
>
> and the resulting warning is:
>
> r_jiba1.c: In function 'PyInit_r_jiba1':
> r_jiba1.c:800: warning: dereferencing type-punned pointer will break
> strict-aliasing rules
> r_jiba1.c:807: warning: dereferencing type-punned pointer will break
> strict-aliasing rules
>
> The problem here is mostly the "self" argument, which has the type of the
> concrete class for each subtype. The code that generates this in the
> generate_exttype_vtable_init_code() function in ModuleNode.py has the type
> casts hard-coded. What would be the right thing to do here? Cast one of the
> functions (rhs?) to the type of the other?
More information about the Pyrex
mailing list