This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients benjamin.peterson, serhiy.storchaka, vstinner
Date 2016-12-02.00:38:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1480639123.61.0.549454845371.issue28855@psf.upfronthosting.co.za>
In-reply-to
Content
_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.
History
Date User Action Args
2016-12-02 00:38:43vstinnersetrecipients: + vstinner, benjamin.peterson, serhiy.storchaka
2016-12-02 00:38:43vstinnersetmessageid: <1480639123.61.0.549454845371.issue28855@psf.upfronthosting.co.za>
2016-12-02 00:38:43vstinnerlinkissue28855 messages
2016-12-02 00:38:43vstinnercreate