Skip site navigation (1) Skip section navigation (2)

Re: refactoring comment.c

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>,Robert Haas <robertmhaas(at)gmail(dot)com>,Kevin Grittner <kevin(dot)grittner(at)wicourts(dot)gov>,Peter Eisentraut <peter_e(at)gmx(dot)net>,pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: refactoring comment.c
Date: 2010-08-28 09:48:01
Message-ID: 20100828094801.GA6488@svana.org (view raw or flat)
Thread:
Lists: pgsql-hackers
On Fri, Aug 27, 2010 at 09:35:55PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)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(at)postgresql(dot)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(at)svana(dot)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

In response to

pgsql-hackers by date

Next:From: Magnus HaganderDate: 2010-08-28 10:16:43
Subject: Re: Git conversion progress report and call for testing assistance
Previous:From: tomasDate: 2010-08-28 07:02:37
Subject: Re: git: uh-oh

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group