Re: Warnings in compile - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Warnings in compile
Date
Msg-id 4263.1243267849@sss.pgh.pa.us
Whole thread Raw
In response to Re: Warnings in compile  (Michael Meskes <meskes@postgresql.org>)
Responses Re: Warnings in compile  (Michael Meskes <meskes@postgresql.org>)
Re: Warnings in compile  (Michael Meskes <meskes@postgresql.org>)
List pgsql-hackers
Michael Meskes <meskes@postgresql.org> writes:
> On Mon, May 25, 2009 at 11:27:27AM -0400, Tom Lane wrote:
>> You can't just remove the "else", or it's unsafe;

> But why? What does this empty else accomplish?

Consider
if (...)    macro;else    something-else;

Without the "else" in the macro, this code would be parsed
in a surprising fashion, ie else bound to the wrong if.
I'm afraid that "else {}" might not be any better --- it
might fail outright in this context.

[ thinks for a bit... ]  What might be both safe and warning-free
is to code an explicit empty statement, viz macro body as
if (1) { ... } else ((void) 0)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Zdenek Kotala
Date:
Subject: problem with plural-forms
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] cleanup hashindex for pg_migrator hashindex compat mode (for 8.4)