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 gdr@garethrees.org
Recipients gdr@garethrees.org, lemburg, mark.dickinson, rhettinger, vstinner
Date 2021-10-15.11:01:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634295687.53.0.183322990725.issue45476@roundup.psfhosted.org>
In-reply-to
Content
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)
History
Date User Action Args
2021-10-15 11:01:27gdr@garethrees.orgsetrecipients: + gdr@garethrees.org, lemburg, rhettinger, mark.dickinson, vstinner
2021-10-15 11:01:27gdr@garethrees.orgsetmessageid: <1634295687.53.0.183322990725.issue45476@roundup.psfhosted.org>
2021-10-15 11:01:27gdr@garethrees.orglinkissue45476 messages
2021-10-15 11:01:27gdr@garethrees.orgcreate