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 1sWghg-00GkFI-1m for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jul 2024 18:27:07 +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 1sWghd-007Pqd-QA for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jul 2024 18:27:05 +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 1sWghd-007PqU-GM for pgsql-hackers@lists.postgresql.org; Wed, 24 Jul 2024 18:27:05 +0000 Received: from fout3-smtp.messagingengine.com ([103.168.172.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sWghW-001FEe-L4; Wed, 24 Jul 2024 18:27:04 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id 00B0F13801B5; Wed, 24 Jul 2024 14:26:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 24 Jul 2024 14:26:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm2; t=1721845616; x=1721932016; bh=WTdyclgjtjkPKfglzyPaw8J5qxJczmo/ zO0mKFuuHnA=; b=d7H/MY7POjCVgNrdoBG7YVYoRuFL2nEa4/HXlZsZ/+RaxZ5w 1Kpom81U68xiv2Wn/3fb7Sx1cfigzTsv0ocF8de2bMuy+ldGXS4EhFDi7C3cByj8 T5v9t0pSj9y52EnbN1olu7siEoARbZ9ETIcS+AvYPz6fsxsJbuER4KYjCTEu3p7Y v4Xj/lN68lY8GEI5RF3yhB1x6zjKiOjuX0fV+XfUYedYJmDqudaMSZYu7XHfSqAn rHxl24/8NgMP1iz8gK6FKAOzTssZ+bT4JbmLcRHZVvL+lq7BAcxJeSWp/ivIBkRS pnjFGMhkqxIHd93ZlAYxRKLMrK8+VD1+58IJsA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1721845616; x= 1721932016; bh=WTdyclgjtjkPKfglzyPaw8J5qxJczmo/zO0mKFuuHnA=; b=q w6vVT4/f4VJj5o5hnuBtLRpRHLYRvRZ76ngzqDSH7gzWiu+8ah2iSbhFW7m1dJ0W FcvFi5C8e0HQpgxU+VVepZIplulUM+WZMV1qal4s44FbpJyoIGNSDTQK2P+S4Pno LN1eMnCPfivYFQX9/Y7+JEUEGV/svxp5zIy1RTXHe2glabczUNAlsnAuyapdxMUw zAr23xxthbEjdhyQ0V8ndCOXrCJ9RH302xo2/6sklVG0M/PXqa87wBMjzhVn+SzH tQNLL5h3WhixISNV2t6BsHDXz/sr/iqKjJbceYlsjwHtsqQ1TmMuzujTa7HWCRUP 4enG+cYCwJo9FXxqMO/Ig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddriedugdduvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgh eqnecuggftrfgrthhtvghrnhepgfejtdfhkeeftdeugfeileehteeljeeghfeuledthfeu tedvffdukeefjefhgeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgpdhnsggprhgtphht thhopedt X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 Jul 2024 14:26:56 -0400 (EDT) Message-ID: Date: Wed, 24 Jul 2024 20:26:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: warning: dereferencing type-punned pointer To: Tom Lane Cc: Tatsuo Ishii , pgsql-hackers@postgresql.org References: <20240724.155525.366150353176322967.ishii@postgresql.org> <1218071.1721829945@sss.pgh.pa.us> <1fe7031f-3a25-40c3-b244-530ea42fc133@eisentraut.org> <1254018.1721844589@sss.pgh.pa.us> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <1254018.1721844589@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 24.07.24 20:09, Tom Lane wrote: > 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? It must have to do with the fact that the escontext field in JsonExprState has the object inline, not as a pointer. AIUI, with dynamically allocated objects you have more liberties about what type to interpret them as than with actually declared objects. If you change the member to a pointer - ErrorSaveContext escontext; + ErrorSaveContext *escontext; } JsonExprState; and make the required adjustments elsewhere in the code, the warning goes away. This arrangement would also appear to be more consistent with other executor nodes (e.g., ExprState, ExprEvalStep), so it might be worth it for consistency in any case.