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 1sWgR7-00GiPa-Vw for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jul 2024 18:10:01 +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 1sWgR5-007I0J-5W for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jul 2024 18:09:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sWgR4-007I0B-Ru for pgsql-hackers@lists.postgresql.org; Wed, 24 Jul 2024 18:09:58 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sWgQy-001Gjw-It; Wed, 24 Jul 2024 18:09:58 +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 46OI9nHi1254019; Wed, 24 Jul 2024 14:09:49 -0400 From: Tom Lane To: Peter Eisentraut cc: Tatsuo Ishii , pgsql-hackers@postgresql.org Subject: Re: warning: dereferencing type-punned pointer In-reply-to: <1fe7031f-3a25-40c3-b244-530ea42fc133@eisentraut.org> References: <20240724.155525.366150353176322967.ishii@postgresql.org> <1218071.1721829945@sss.pgh.pa.us> <1fe7031f-3a25-40c3-b244-530ea42fc133@eisentraut.org> Comments: In-reply-to Peter Eisentraut message dated "Wed, 24 Jul 2024 19:53:47 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1254017.1721844589.1@sss.pgh.pa.us> Date: Wed, 24 Jul 2024 14:09:49 -0400 Message-ID: <1254018.1721844589@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > On 24.07.24 16:05, Tom Lane wrote: >> I'm not very thrilled with these changes. It's not apparent why >> your compiler is warning about these usages of IsA and not any other >> ones, > I think one difference is that normally IsA is called on a Node * (since > you call IsA to decide what to cast it to), but in this case it's called > on a pointer that is already of type ErrorSaveContext *. Hmm. But there are boatloads of places where we call IsA on a pointer of type Expr *, or sometimes other things. Why aren't those triggering the same warning? > I think here you could just bypass the SOFT_ERROR_OCCURRED macro: > - if (SOFT_ERROR_OCCURRED(&jsestate->escontext)) > + if (jsestate->escontext.error_occurred) Perhaps. That's a bit sad because it's piercing a layer of abstraction. I do not like compiler warnings that can't be gotten rid of without making the code objectively worse. regards, tom lane