Gareth Rees <[email protected]> added the comment:
If the problem is accidental use of the result of PyFloat_AS_DOUBLE() as an
lvalue, why not use the comma operator to ensure that the result is an rvalue?
The C99 standard says "A comma operator does not yield an lvalue" in ยง6.5.17; I
imagine there is similar text in other versions of the standard.
The idea would be to define a helper macro like this:
/* As expr, but can only be used as an rvalue. */
#define Py_RVALUE(expr) ((void)0, (expr))
and then use the helper where needed, for example:
#define PyFloat_AS_DOUBLE(op) Py_RVALUE(((PyFloatObject *)(op))->ob_fval)
----------
nosy: [email protected]
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45476>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com