Re: [PATCH v1] remove redundant check of item pointer - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: [PATCH v1] remove redundant check of item pointer
Date
Msg-id CAH2-WzmH7uax50-GyOKXPP_YA-suwXgTcT3N-58rxQWx_Qxksw@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH v1] remove redundant check of item pointer  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCH v1] remove redundant check of item pointer
Next
From: Andres Freund
Date:
Subject: Re: doc: New cumulative stats subsystem obsoletes comment in maintenance.sgml