Pointer subtraction with a null pointer
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Cc: Andres Freund <andres@anarazel.de>, Robert Haas <robertmhaas@gmail.com>,
Thomas Munro <thomas.munro@gmail.com>
Date: 2022-03-26T16:04:54Z
Lists: pgsql-hackers
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
Commits
-
Suppress compiler warning in relptr_store().
- e07d4ddc55fd 15.0 landed
- 403a8c76293b 10.21 landed
- a2a1aa830a1c 11.16 landed
- cb8586d0514b 12.11 landed
- 4fbbea2c1934 13.7 landed
- 0144c9c7e73d 14.3 landed