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 1l8vDq-0001WS-Ry for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Feb 2021 01:20:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l8vDo-00089T-GB for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Feb 2021 01:20:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8vDo-00089L-9E for pgsql-hackers@lists.postgresql.org; Mon, 08 Feb 2021 01:20:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8vDm-00063N-Cf; Mon, 08 Feb 2021 01:20:11 +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 1181K0X6477103; Sun, 7 Feb 2021 20:20:00 -0500 From: Tom Lane To: Alexander Korotkov cc: Heikki Linnakangas , Alexander Korotkov , pgsql-hackers@lists.postgresql.org Subject: Re: Detecting pointer misalignment (was Re: pgsql: Implementation of subscripting for jsonb) In-reply-to: <475514.1612745257@sss.pgh.pa.us> References: <37bb56a0-391d-759d-771b-9c1d8c15a84b@iki.fi> <3293925.1612163110@sss.pgh.pa.us> <475514.1612745257@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sun, 07 Feb 2021 19:47:37 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <477101.1612747200.1@sss.pgh.pa.us> Date: Sun, 07 Feb 2021 20:20:00 -0500 Message-ID: <477102.1612747200@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > * Both clang and gcc seem to be happy with the same spelling of the > function attribute, which is fortunate. However, I seriously doubt > that bare "#ifdef __GNUC__" is going to be good enough. At the very > least there's going to need to be a compiler version test in there, > and we might end up needing to get the configure script involved. After digging in gcc's release history, it seems they invented "-fsanitize=alignment" in GCC 5, so we can make this work for gcc by writing #if __GNUC__ >= 5 (the likely() macro already uses a similar approach). Can't say if that's close enough for clang too. regards, tom lane