Re: elog/ereport noreturn decoration

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: elog/ereport noreturn decoration
Дата
Msg-id 15939.1341005734@sss.pgh.pa.us
обсуждение исходный текст
Ответ на elog/ereport noreturn decoration  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: elog/ereport noreturn decoration  (Peter Geoghegan <peter@2ndquadrant.com>)
Re: elog/ereport noreturn decoration  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> I think the issue here was that if we support two separate code paths,
> we still need to do the actually unreachable /* keep compiler happy */
> bits, and that compilers that know about elog not returning would
> complain about unreachable code.

Yes.  The problem with trying to change that is that it's damned if you
do and damned if you don't: compilers that are aware that abort()
doesn't return will complain about unreachable code if we keep those
extra variable initializations, while those that are not so aware will
complain about uninitialized variables if we don't.  I don't think
that's going to be a step forward.  IOW I am not on board with reducing
the number of warnings in clang by increasing the number everywhere
else.

Perhaps we could do something like
       default:           elog(ERROR, "unrecognized drop object type: %d",                (int) drop->removeType);
-           relkind = 0;                     /* keep compiler quiet */
+           UNREACHABLE(relkind = 0);        /* keep compiler quiet */           break;

where UNREACHABLE(stuff) expands to the given statements (possibly
empty) or to abort() depending on the compiler's properties.  If we
did something like that we'd not need to monkey with the definition
of either elog or ereport, but instead we'd have to run around and
fix everyplace that was emitting warnings of this sort.
        regards, tom lane


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

Предыдущее
От: Dimitri Fontaine
Дата:
Сообщение: Re: Event Triggers reduced, v1
Следующее
От: Dimitri Fontaine
Дата:
Сообщение: Re: Event Triggers reduced, v1