Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nY8uW-0002yu-6C for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Mar 2022 16:05:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nY8uU-0008Hb-MO for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Mar 2022 16:05:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nY8uU-0008HS-DB for pgsql-hackers@lists.postgresql.org; Sat, 26 Mar 2022 16:05:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nY8uS-0001EY-6G for pgsql-hackers@lists.postgresql.org; Sat, 26 Mar 2022 16:05:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 22QG4smH048827; Sat, 26 Mar 2022 12:04:54 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org cc: Andres Freund , Robert Haas , Thomas Munro Subject: Pointer subtraction with a null pointer MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <48825.1648310694.1@sss.pgh.pa.us> Date: Sat, 26 Mar 2022 12:04:54 -0400 Message-ID: <48826.1648310694@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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