[Python-Dev] Py_DECREF causes spurious gcc warning

Martin v. Löwis martin at v.loewis.de
Thu Dec 18 16:27:30 EST 2003

Skip Montanaro <skip at pobox.com> writes:

> I meant the Py_*REF macros which expand to "if" statements and you'd bracify
> the clauses, e.g., Py_DECREF would become:

That would still trigger the warning about

  if(1) Py_DECREF(foo);

as this expands to

  if(1) if(cond(foo)) {action1(foo);} else {action2(foo);}

This, in turn, is potentially unintended, as the author of that code
may have meant the else to go with the if(1), whereas, in C, it goes
with the if(cond(foo)). As Tim explains, the intended semantics is the
desired one, too, so there is really no problem in the code. As Tim
also explains, do{}while(1) would silence the warning.


More information about the Python-Dev mailing list