Re: elog/ereport noreturn decoration - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: elog/ereport noreturn decoration
Date
Msg-id 1342303177.28562.12.camel@vanquo.pezone.net
Whole thread Raw
In response to Re: elog/ereport noreturn decoration  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: elog/ereport noreturn decoration  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On lör, 2012-06-30 at 10:52 -0400, Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.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

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Getting rid of pre-assignment of index names in CREATE TABLE LIKE
Next
From: Tom Lane
Date:
Subject: Re: elog/ereport noreturn decoration