Re: elog/ereport noreturn decoration

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: elog/ereport noreturn decoration
Date: 2012-07-14 21:59:37
Message-ID: 1342303177.28562.12.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On lör, 2012-06-30 at 10:52 -0400, Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > But my point was, there aren't any unused code warnings. None of the
> > commonly used compilers issue any. I'd be interested to know if there
> > is any recent C compiler supported by PostgreSQL that issues some kind
> > of unused code warning under any circumstances, and see an example of
> > that. Then we can determine whether there is an issue here.
>
> Well, the Solaris Studio compiler produces "warning: statement not
> reached" messages, as seen for example on buildfarm member castoroides.
> I don't have one available to experiment with, so I'm not sure whether
> it knows that abort() doesn't return; but I think it rather foolish to
> assume that such a combination doesn't exist in the wild.

A small sidetrack here. I've managed to set up the Solaris Studio
compiler on Linux and tried this out. It turns out these "statement not
reached" warnings have nothing to do with knowledge about library
functions such as abort() or exit() not returning. The warnings come
mostly from loops that never end (except by returning from the function)
and some other more silly cases where the supposed fallback return
statement is clearly unnecessary. I think these should be fixed,
because the code is wrong and could mask real errors if someone ever
wanted to rearrange those loops or something.

Patch attached. I tried this out with old and new versions of gcc,
clang, and the Solaris compiler, and everyone was happy about. I didn't
touch the regex code. And there's some archeological knowledge about
Perl in there.

The Solaris compiler does not, by the way, complain about the elog patch
I had proposed.

Attachment Content-Type Size
pg-not-reached.patch text/x-patch 7.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-07-14 22:16:12 Re: elog/ereport noreturn decoration
Previous Message Tom Lane 2012-07-14 20:02:29 Getting rid of pre-assignment of index names in CREATE TABLE LIKE