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 1sWgkK-00GkRv-0f for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jul 2024 18:29: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 1sWgkI-007SKl-90 for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Jul 2024 18:29: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 1sWgkH-007SKd-Ve for pgsql-hackers@lists.postgresql.org; Wed, 24 Jul 2024 18:29: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 1sWgkF-001FFq-Fz; Wed, 24 Jul 2024 18:29: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 46OITjj91256315; Wed, 24 Jul 2024 14:29:45 -0400 From: Tom Lane To: Peter Eisentraut cc: Tatsuo Ishii , pgsql-hackers@postgresql.org Subject: Re: warning: dereferencing type-punned pointer In-reply-to: <1254018.1721844589@sss.pgh.pa.us> 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> Comments: In-reply-to Tom Lane message dated "Wed, 24 Jul 2024 14:09:49 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1256313.1721845785.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 24 Jul 2024 14:29:45 -0400 Message-ID: <1256314.1721845785@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk BTW, I tried the same experiment of building without -fno-strict-aliasing using gcc 11.4.1 (from RHEL9). I see one more warning than Tatsuo-san did: In file included from verify_heapam.c:18: verify_heapam.c: In function =E2=80=98check_tuple_attribute=E2=80=99: ../../src/include/access/toast_internals.h:37:11: warning: dereferencing t= ype-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 37 | (((toast_compress_header *) (ptr))->tcinfo >> VARLENA_EXTS= IZE_BITS) | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ verify_heapam.c:1693:24: note: in expansion of macro =E2=80=98TOAST_COMPRE= SS_METHOD=E2=80=99 1693 | cmid =3D TOAST_COMPRESS_METHOD(&toast_pointer); | ^~~~~~~~~~~~~~~~~~~~~ This looks a bit messy to fix: we surely don't want to pierce the abstraction TOAST_COMPRESS_METHOD provides. Perhaps the toast_pointer local variable could be turned into a union of struct varatt_external and toast_compress_header, but that would impose a good deal of notational overhead on the rest of this function. The good news is that we get through check-world (although I didn't try very many build options). regards, tom lane