Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qg4cJ-00ENYf-I5 for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Sep 2023 14:43:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qg4cI-009Bmu-Cr for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Sep 2023 14:43:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qg4cI-009Bml-2v for pgsql-hackers@lists.postgresql.org; Tue, 12 Sep 2023 14:43:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qg4cE-004ADA-W7 for pgsql-hackers@postgresql.org; Tue, 12 Sep 2023 14:43:48 +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 38CEhfqf2797649; Tue, 12 Sep 2023 10:43:41 -0400 From: Tom Lane To: Peter Eisentraut cc: Alvaro Herrera , Amit Langote , Erik Rijkers , jian he , Andrew Dunstan , PostgreSQL-development Subject: Re: remaining sql/json patches In-reply-to: References: <202309061501.xcwpfa2jjj5n@alvherre.pgsql> Comments: In-reply-to Peter Eisentraut message dated "Tue, 12 Sep 2023 09:52:50 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2797647.1694529821.1@sss.pgh.pa.us> Date: Tue, 12 Sep 2023 10:43:41 -0400 Message-ID: <2797648.1694529821@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > On 06.09.23 17:01, Alvaro Herrera wrote: >> Assert()ing that a pointer is not null, and in the next line >> dereferencing that pointer, is useless: the process would crash anyway >> at the time of dereference, so the Assert() adds no value. Better to >> leave the assert out. > I don't think this is quite correct. If you dereference a pointer, the > compiler may assume that it is not null and rearrange code accordingly. > So it might not crash. Keeping the assertion would alter that assumption. Uh ... only in assert-enabled builds. If your claim is correct, this'd result in different behavior in debug and production builds, which would be even worse. But I don't believe the claim. I side with Alvaro's position here: such an assert is unhelpful. regards, tom lane