[Python-Dev] Py_DECREF causes spurious gcc warning (original) (raw)
Tim Peters tim.one at comcast.net
Wed Dec 17 19:24:02 EST 2003
- Previous message: [Python-Dev] Py_DECREF causes spurious gcc warning
- Next message: [Python-Dev] Py_DECREF causes spurious gcc warning
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Edward C. Jones]
I use Gentoo 1.4 Linux with gcc 3.2.2. The C program given below gives the following compiler message:
silly.c: In function
silly':_ _silly.c:5: warning: suggest explicit braces to avoid ambiguouselse' I doubt if there is any bug in PyDECREF. But would it be possible to jiggle the PyDECREF macros to suppress this message? In my real code, I, of course, just added braces.
Sounds good to me (i.e., add the braces and be done with it). It's a silly warning because Py_DECREF expands to a two-branch if/else, and there is no ambiguity in reality. It would be a refreshing change if someone suggested that gcc change instead .
[Timothy Delany]
If you mean you changed it to:
static PyObject* silly(PyObject* obj, PyObject *args) { if (1) { PyDECREF(PyNone); } then I would say that's the right thing to do - all the time, in all code.
[Skip Montanaro]
Then you also agree we should bracify the Py*REF macros, right?
That can't work, alas -- the macro has no idea whether curly braces are syntactically legal in the context it's invoked in. Timmy can know that, and insert them or not accordingly.
This is what leads to the bletcherous
do {
the real macro guts go here
} while(0)form of macro definition. Py_DECREF could be rewritten in that form -- but I've puked enough for one day .
- Previous message: [Python-Dev] Py_DECREF causes spurious gcc warning
- Next message: [Python-Dev] Py_DECREF causes spurious gcc warning
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]