Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

bpo-33012: (invalid) function cast warnings with gcc 8 #265

@akruis

Description

@akruis

gcc 8 has added a new warning heuristic to detect invalid function casts and a Stackless python build seems to hit that warning quite often. Most, but not all warnings a re invalid.

For details how to fix these warnings see https://bugs.python.org/issue33012

To identify valid warnings, I sorted and group the warnings. For instance for casts to (PyCFunction):
fgrep '[-Wcast-function-type]' make.log | grep '^Stackless' | fgrep 'to ‘PyObject * (*)(PyObject *, PyObject *)’' | cut -d ' ' -f 9- | sort -u
emits

‘int (*)(PyChannelObject *, PyObject *)’ {aka ‘int (*)(struct _channel *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyAsyncGenObject *)’ {aka ‘struct _object * (*)(struct <anonymous> *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyBombObject *)’ {aka ‘struct _object * (*)(struct _bomb *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyCellObject *)’ {aka ‘struct _object * (*)(struct <anonymous> *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyCFrameObject *)’ {aka ‘struct _object * (*)(struct _cframe *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyChannelObject *)’ {aka ‘struct _object * (*)(struct _channel *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyCodeObject *)’ {aka ‘struct _object * (*)(struct <anonymous> *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyCoroObject *)’ {aka ‘struct _object * (*)(struct <anonymous> *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(_PyDictViewObject *)’ {aka ‘struct _object * (*)(struct <anonymous> *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyFrameObject *)’ {aka ‘struct _object * (*)(struct _frame *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyFunctionObject *)’ {aka ‘struct _object * (*)(struct <anonymous> *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyGenObject *)’ {aka ‘struct _object * (*)(struct <anonymous> *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘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]
‘PyObject * (*)(PyStacklessFunctionDeclarationObject *)’ {aka ‘struct _object * (*)(struct <anonymous> *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyTaskletObject *)’ {aka ‘struct _object * (*)(struct _tasklet *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyTaskletObject *, PyObject * const*, Py_ssize_t,  PyObject *)’ {aka ‘struct _object * (*)(struct _tasklet *, struct _object * const*, long int,  struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(PyTypeObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _typeobject *, struct _object *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
‘PyObject * (*)(tracebackobject *)’ {aka ‘struct _object * (*)(struct _traceback *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]

It is obvious, that the first line looks fishy, because the function returns int instead of PyObject *. But I inspect all cases.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions