Re: elog/ereport noreturn decoration

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: elog/ereport noreturn decoration
Дата
Msg-id 1342303177.28562.12.camel@vanquo.pezone.net
обсуждение исходный текст
Ответ на Re: elog/ereport noreturn decoration  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: elog/ereport noreturn decoration  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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.


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Getting rid of pre-assignment of index names in CREATE TABLE LIKE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: elog/ereport noreturn decoration