[Python-Dev] Py_DECREF causes spurious gcc warning
tim.one at comcast.net
Wed Dec 17 19:24:02 EST 2003
[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 ambiguous `else'
> I doubt if there is any bug in Py_DECREF. But would it be possible to
> jiggle the Py_DECREF 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 <wink>.
> If you mean you changed it to:
> static PyObject* silly(PyObject* obj, PyObject *args)
> if (1)
> then I would say that's the right thing to do - all the
> time, in all code.
> 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
the real macro guts go here
form of macro definition. Py_DECREF could be rewritten in that form -- but
I've puked enough for one day <splat>.
More information about the Python-Dev