Re: refactoring comment.c - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: refactoring comment.c
Date
Msg-id 20100828094801.GA6488@svana.org
Whole thread Raw
In response to Re: refactoring comment.c  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Aug 27, 2010 at 09:35:55PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre@commandprompt.com> writes:
> > Didn't we inject some smarts so that the compiler would notice that
> > elog(ERROR) doesn't return?
>
> No.  If you know a portable (as in "works on every compiler") way
> to do that, we could talk.  If only some compilers understand it,
> we'll probably end up worse off --- the ones that don't understand it
> will still need things like these unreachable assignments, while the
> ones that do understand will start warning about unreachable code.

We've been here before:

http://www.mail-archive.com/pgsql-hackers@postgresql.org/msg72113.html

The problem appears to be mainly avoiding double evaluation, as
otherwise it's just some macro tweaking. On gcc you can avoid the
double evaluation also, but it's other compilers which we also need to
support.

If we really wanted to we could arrange for GCC to throw an error if
the first argument to elog was non-constant, which would prevent bugs
creeping in due to double evaluation. That still won't help users of
other compilers though.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patriotism is when love of your own people comes first; nationalism,
> when hate for people other than your own comes first.
>                                       - Charles de Gaulle

pgsql-hackers by date:

Previous
From: tomas@tuxteam.de
Date:
Subject: Re: git: uh-oh
Next
From: Magnus Hagander
Date:
Subject: Re: Git conversion progress report and call for testing assistance