pgsql: Suppress compiler warning in relptr_store().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Suppress compiler warning in relptr_store().
Date: 2022-03-26 18:30:27
Message-ID: E1nYBBC-001V5u-Vw@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Suppress compiler warning in relptr_store().

clang 13 with -Wextra warns that "performing pointer subtraction with
a null pointer has undefined behavior" in the places where freepage.c
tries to set a relptr variable to constant NULL. This appears to be
a compiler bug, but it's unlikely to get fixed instantly. Fortunately,
we can work around it by introducing an inline support function, which
seems like a good change anyway because it removes the macro's existing
double-evaluation hazard.

Backpatch to v10 where this code was introduced.

Patch by me, based on an idea of Andres Freund's.

Discussion: https://postgr.es/m/48826.1648310694@sss.pgh.pa.us

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0144c9c7e73dc75f9cd5297c7c380d55927beb75

Modified Files
--------------
src/include/utils/relptr.h | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2022-03-26 18:40:06 Re: pgsql: Add 'basebackup_to_shell' contrib module.
Previous Message Tomas Vondra 2022-03-26 18:14:49 pgsql: Move prattrs to the pg_publication_rel section in docs