From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Cc: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Thomas Munro <thomas.munro@gmail.com>
Subject: Pointer subtraction with a null pointer
Date: Sat, 26 Mar 2022 12:04:54 -0400
Message-ID: <48826.1648310694@sss.pgh.pa.us> (raw)
Several of Andres' buildfarm animals have recently started to whine
that "performing pointer subtraction with a null pointer has undefined
behavior" for assorted places in freepage.c.
From a mathematical standpoint, this astonishes me: "x - 0 = x" is a
tautology. So I'm a bit inclined to say "you're full of it" and disable
-Wnull-pointer-subtraction. On the other hand, all of the occurrences
are in calls of relptr_store with a constant-NULL third argument.
So we could silence them without too much pain by adjusting that macro
to special-case NULL. Or maybe we should change these call sites to do
something different, because this is surely abusing the intent of
relptr_store.
Thoughts?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org, andres@anarazel.de, robertmhaas@gmail.com, thomas.munro@gmail.com
Subject: Re: Pointer subtraction with a null pointer
In-Reply-To: <48826.1648310694@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox