Re: Using ASSUME in place of ASSERT in non-assert builds

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Benjamin Coutu <ben(dot)coutu(at)zeyos(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Using ASSUME in place of ASSERT in non-assert builds
Date: 2025-07-10 15:35:26
Message-ID: 1529814.1752161726@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Benjamin Coutu <ben(dot)coutu(at)zeyos(dot)com> writes:
> That got me thinking: some projects (like PHP) map the ASSERT macro to ASSUME in non-assert builds. The rationale is that ASSERT typically expresses a tautology, something the programmer believes to be always true. So in builds where assertions are compiled out, we can still pass that information to the optimizer via ASSUME.

My gut instinct is that this would not help much; we don't typically
write assertions that would help the compiler all that much. And
in any case, to my mind there is a considerable difference in goals
between Assert and Assume, which I'd prefer not to fuzz like this.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhou, Zhiguo 2025-07-10 15:57:01 Re: Optimize shared LWLock acquisition for high-core-count systems
Previous Message Tomas Vondra 2025-07-10 15:31:45 Re: Adding basic NUMA awareness