Message404001
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) |
|
Date |
User |
Action |
Args |
2021-10-15 11:01:27 | gdr@garethrees.org | set | recipients:
+ gdr@garethrees.org, lemburg, rhettinger, mark.dickinson, vstinner |
2021-10-15 11:01:27 | gdr@garethrees.org | set | messageid: <1634295687.53.0.183322990725.issue45476@roundup.psfhosted.org> |
2021-10-15 11:01:27 | gdr@garethrees.org | link | issue45476 messages |
2021-10-15 11:01:27 | gdr@garethrees.org | create | |
|