Bugs item #1113244, was opened at 2005-01-31 11:01
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1113244&group_id=5470
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Richard Kettlewell (rjk1002)
>Assigned to: Nobody/Anonymous (nobody)
Summary: Please add do-while guard to Py_DECREF etc.
Initial Comment:
Py_DECREF() is missing do-while macro guards (as found
e.g. in Py_CLEAR), instead relying on being an if-else
to avoid the usual problems associated with such macros.
However if it is used as e.g. "if (newref)
Py_DECREF(obj);" then gcc -Wall still complains about
an ambiguous else clause. (gcc version is 3.3.5)
Granted it is only a warning but like many people we
build with -Werror, and the code in question is in SWIG
output rather than our own code, so this is quite
painful for us.
At least Py_DECREF, Py_XDECREF and Py_XINCREF need
fixing; I've not checked beyond this.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2005-02-01 21:03
Message:
Logged In: YES
user_id=31435
rjk1002: it's idiotic complaints about unambigous (in reality)
if/else structures that are unique to gcc. Not all compilers
optimize away the "do {...} while(0)" cruft in debug builds;
the most important examples for Python are the Microsoft
compilers. Because the incref and decref macros are used a
*lot*, it's unattractive to burden all platforms with this just
to shut up one compiler. I don't care about Py_CLEAR()
(etc), because they're so lightly used. The incref/decref
macros are ubiquitous.
I would much rather see SWIG change to insert curlies. That
is, generating "if (newref) {Py_DECREF(obj);}" should be just
as effective at shutting up this gcc nag. Has anyone asked
the SWIG project to do this?
----------------------------------------------------------------------
Comment By: Richard Kettlewell (rjk1002)
Date: 2005-02-01 04:51
Message:
Logged In: YES
user_id=217390
Making it compiler-specific seems silly. It's not like the
do-while idiom for macros is some strange gcc-specific
thing; most people just use it unconditionally on
complicated macros.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2005-01-31 21:53
Message:
Logged In: YES
user_id=80475
Tim, what you think about doing this with a conditional
compile to only redefine for GCC?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1113244&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com