From: | Peter Geoghegan <pg(at)bowt(dot)ie> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Bruce Momjian <bruce(at)momjian(dot)us>, Junwang Zhao <zhjwpku(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH v1] remove redundant check of item pointer |
Date: | 2022-07-14 23:10:20 |
Message-ID: | CAH2-WzmH7uax50-GyOKXPP_YA-suwXgTcT3N-58rxQWx_Qxksw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Jul 14, 2022 at 3:59 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2022-07-14 23:31:01 | Re: doc: New cumulative stats subsystem obsoletes comment in maintenance.sgml |
Previous Message | Tom Lane | 2022-07-14 22:59:11 | Re: [PATCH v1] remove redundant check of item pointer |