Re: do {} while (0) nitpick - Mailing list pgsql-hackers

From Tom Lane
Subject Re: do {} while (0) nitpick
Date
Msg-id 3065.1588297870@sss.pgh.pa.us
Whole thread Raw
In response to do {} while (0) nitpick  (John Naylor <john.naylor@2ndquadrant.com>)
Responses Re: do {} while (0) nitpick
List pgsql-hackers
John Naylor <john.naylor@2ndquadrant.com> writes:
> As I understand it, the point of having "do {} while (0)" in a
> multi-statement macro is to turn it into a simple statement.

Right.

> As such,
> ending with a semicolon in both the macro definition and the
> invocation will turn it back into multiple statements, creating
> confusion if someone were to invoke the macro in an "if" statement.

Yeah.  I'd call these actual bugs, and perhaps even back-patch worthy.

            regards, tom lane



pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: do {} while (0) nitpick
Next
From: Bruce Momjian
Date:
Subject: Re: do {} while (0) nitpick