Re: Pointer subtraction with a null pointer
Isaac Morland <isaac.morland@gmail.com>
From: Isaac Morland <isaac.morland@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>,
Robert Haas <robertmhaas@gmail.com>, Thomas Munro <thomas.munro@gmail.com>
Date: 2022-03-26T16:34:10Z
Lists: pgsql-hackers
On Sat, 26 Mar 2022 at 12:24, Andres Freund <andres@anarazel.de> wrote: > NULL can never be part of the same "array object" or one past past the last > element as the pointer it is subtracted from. Hence the undefined beaviour. > Even more fundamentally, NULL is not 0 in any ordinary mathematical sense, even though it can be written 0 in source code and is often (but not always) represented in memory as an all-0s bit pattern. I'm not at all surprised to learn that arithmetic involving NULL is undefined.
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