Cython: '__Pyx__PyObject_Ord' defined but not used

Created on 11 Aug 2016  Â·  4Comments  Â·  Source: cython/cython

For this code:

map(ord, 'foobar')

I get the following compiler warning:

/home/jwilk/maptest.c:1136:13: warning: '__Pyx__PyObject_Ord' defined but not used [-Wunused-function]
 static long __Pyx__PyObject_Ord(PyObject* c) {
             ^

I'd be nice if Cython defined __Pyx__PyObject_Ord only when it's actually going to use it.

Tested with git master, i.e. a767e7e8807aa315de72124daf0f464738ed85af.

Most helpful comment

Not critical bugs as there is nothing going wrong here. But if it is avoidable, then it's a bug to generate useless code, yes. Any C compiler warning that Cython generated code outputs makes it more difficult for users to spot bugs in their own code. And not everyone wants to invest much time into tuning the C compiler warning flags. If users end up disabling all warnings because "it's easier" or because they don't know better, we've done something wrong. And we shouldn't get to that point.

All 4 comments

This should fix it. Let's see if it breaks anything else instead. 1d7072f17e00147e9929175d12b9c4ccf8ae90aa

General question: do you really consider these compiler warnings to be bugs? In SageMath, we are using -Wno-unused to silence all warnings about unused stuff coming from Cython. There are a lot of warnings like that.

Not critical bugs as there is nothing going wrong here. But if it is avoidable, then it's a bug to generate useless code, yes. Any C compiler warning that Cython generated code outputs makes it more difficult for users to spot bugs in their own code. And not everyone wants to invest much time into tuning the C compiler warning flags. If users end up disabling all warnings because "it's easier" or because they don't know better, we've done something wrong. And we shouldn't get to that point.

Looks like this is resolved in latest master.

Was this page helpful?
0 / 5 - 0 ratings