Hi,

does anyone know how to get rid of all the "dereferencing type-punned pointer
will break strict-aliasing rules" warnings that I see in the tests? I mean,
except by switching them off on the gcc command line or passing
"-fno-strict-aliasing". :)

It complains about code lines where we cast public PyTypeObject pointers to
PyObject pointers, as in the following examples:

    PyObject_Call(((PyObject*)&PyString_Type), __pyx_1, NULL);

    Py_INCREF(((PyObject*)&PyString_Type));

and in the first two lines of the function __Pyx_PyObject_IsTrue:

    static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
       if (x == Py_True) return 1;
       else if (x == Py_False) return 0;
       else return PyObject_IsTrue(x);
    }

where Python's bool header file defines Py_True as

    #define Py_True ((PyObject *) &_Py_TrueStruct)


It would be nice if gcc considered PyObject and PyTypeObject equivalent with
respect to the strict aliasing assumptions. Is there any way to rewrite this
to make gcc a bit smarter here?

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to