Message282212
_PyObject_CallArg1() is the following macro:
---
#define _PyObject_CallArg1(func, arg) \
_PyObject_FastCall((func), &(arg), 1)
---
It works well in most cases, but my change 8f258245c391 or change b9c9691c72c5 added compiler warnings, because an argument which is not directly a PyObject* type is passed as "arg".
I tried to cast in the caller: _PyObject_CallArg1(func, (PyObject*)arg), but sadly it doesn't work :-( I get a compiler error.
Another option is to cast after "&" in the macro:
---
#define _PyObject_CallArg1(func, arg) \
- _PyObject_FastCall((func), &(arg), 1)
+ _PyObject_FastCall((func), (PyObject **)&(arg), 1)
---
This option may hide real bugs, so I dislike it.
A better option is to stop using ugly C macros and use a modern static inline function: see attached static_inline.patch. This patch casts to PyObject* before calling _PyObject_CallArg1() to fix warnings.
The question is if compilers are able to emit efficient code for static inline functions using "&" on an argument. I wrote the macro to implement the "&" optimization: convert a PyObject* to a stack of arguments: C array of PyObject* objects. |
|
Date |
User |
Action |
Args |
2016-12-02 00:38:43 | vstinner | set | recipients:
+ vstinner, benjamin.peterson, serhiy.storchaka |
2016-12-02 00:38:43 | vstinner | set | messageid: <1480639123.61.0.549454845371.issue28855@psf.upfronthosting.co.za> |
2016-12-02 00:38:43 | vstinner | link | issue28855 messages |
2016-12-02 00:38:43 | vstinner | create | |
|