Skip to content

Incorrect C function signature casts #2363

@scoder

Description

@scoder

A new warning in gcc-8 detects several incorrect PyCFunction pointer casts in the Cython generated code.

Examples in the test suite:

special_methods_T561.c:23416:16: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
   {"__next__", (PyCFunction)__pyx_pw_20special_methods_T561_11VerySpecial_99__next__, METH_NOARGS|METH_COEXIST, 0},

unused.c:1732:132: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
       if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6unused_6Unused_1cp_unused_simple)) {

genexpr_T715.c:4460:15: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
     {"close", (PyCFunction) __Pyx_Coroutine_Close, METH_NOARGS,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions