Re: [PATCH v1] remove redundant check of item pointer

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: [PATCH v1] remove redundant check of item pointer
Дата
Msg-id CAH2-WzmH7uax50-GyOKXPP_YA-suwXgTcT3N-58rxQWx_Qxksw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH v1] remove redundant check of item pointer  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Thu, Jul 14, 2022 at 3:59 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Even in an assert-enabled build, wouldn't you expect the compiler to
> optimize away the second assertion as unreachable code?

I think that it probably would, even at -O0 (GCC doesn't really allow
you to opt out of all optimizations). I did think of that myself, but
it seemed rather beside the point.

There have been individual cases where individual assertions were
deemed a bit too heavyweight. But those have been few and far between.
I myself tend to use *lots* of technically-redundant assertions like
this for preconditions and postconditions. At worst they're code
comments that are all but guaranteed to stay current.

-- 
Peter Geoghegan



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [PATCH v1] remove redundant check of item pointer
Следующее
От: Andres Freund
Дата:
Сообщение: Re: doc: New cumulative stats subsystem obsoletes comment in maintenance.sgml