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 1l9Gzt-000553-Kc for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Feb 2021 00:35:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l9Gzs-0001RE-Hs for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Feb 2021 00:35:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9Gzs-0001R7-BP for pgsql-hackers@lists.postgresql.org; Tue, 09 Feb 2021 00:35:16 +0000 Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l9Gzp-00014V-Q0 for pgsql-hackers@lists.postgresql.org; Tue, 09 Feb 2021 00:35:16 +0000 Received: by mail-il1-x130.google.com with SMTP id e1so14621290ilu.0 for ; Mon, 08 Feb 2021 16:35:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=alByUxmt09538wPMGd7K4llY6AyflLzBc2eDmvGmvao=; b=oAgcPZMY5Y3+ZTcvGsNldmVkFFBgFkqCZHm+PNL+BbkFDS5GTkcNP7LqYF4p+pe6Ht VbUFceBADk6nbnhnEzwEAlBCsRV6xbCZIHgdzgcdV8a3w2i/ZNN1oAOCEGTLg29Htq+f IDIvIr1Uuzhjbk9f5BRJB+zfvcI9t60irx9wqFfOxF8K/tCqCYigaunlhpGMvxbDVvpO 3qsKSEkCEPTSoLR6BFoVlPQRb9bnxt44OJpvhH0lf1aS7dhWpEVx8EVhzg8X/1yo50WB aoF1JgMOT4/id0ta58ouVzSVzRn+TMLw4m042jd1vW7c890hsr6oxamzvf5Fiuz+qQE0 lglg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=alByUxmt09538wPMGd7K4llY6AyflLzBc2eDmvGmvao=; b=aEWwKMWtWGE2KdZv1SkA3SAczpr6rV39spIGFfXM1SVsLcqxJZkP++IGdVNISOcApN IRxvzuRLQroIz/i+SEQK3sTknecUqGbVSQZqfTSfTbPnp3quodGs4GuK+f8pDH8HdFQR vih6dc/IXnydJUAYbwNAfxTJAvAZu9Ky1ecf+4qKZBM/b7N1cpZvV8+skS0VGEiMMoZW RkvXRQAZuRNNrVX/7DICmMqHRIF5SqqtTvq+1/CdiHRkCJUHRGQypYI6eKLANYv8dnuJ NpBikHDfIoLcSMx9oFi3Ub84C++hNY86MKJ+Iw3CQRO3PQilP7lsNdxZ9Zl/+tx0jr21 HSkQ== X-Gm-Message-State: AOAM531efDtuhLvTWmrzzIuEeJuqJgIPinrExDfJNyruVSb4U0XK/4uX hMif82QJaz+aU89ert4+JU+Mb57rXPguEOioouk= X-Google-Smtp-Source: ABdhPJyP0Bm5uyibvJgJwAfoV+eG0O0ENOMQZlSoTgOJ5pM7+z1j1XzUbB6Ml5NJuo/foDPQv01+rsWaFpCjNBGDzMQ= X-Received: by 2002:a05:6e02:1d09:: with SMTP id i9mr18265296ila.207.1612830912140; Mon, 08 Feb 2021 16:35:12 -0800 (PST) MIME-Version: 1.0 References: <37bb56a0-391d-759d-771b-9c1d8c15a84b@iki.fi> <3293925.1612163110@sss.pgh.pa.us> <475514.1612745257@sss.pgh.pa.us> <477102.1612747200@sss.pgh.pa.us> <628089.1612802981@sss.pgh.pa.us> In-Reply-To: <628089.1612802981@sss.pgh.pa.us> From: Alexander Korotkov Date: Tue, 9 Feb 2021 03:35:01 +0300 Message-ID: Subject: Re: Detecting pointer misalignment (was Re: pgsql: Implementation of subscripting for jsonb) To: Tom Lane Cc: Heikki Linnakangas , Alexander Korotkov , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Feb 8, 2021 at 7:49 PM Tom Lane wrote: > I wrote: > > 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. > > Ugh, no it isn't: even pretty recent clang releases only define > __GNUC__ as 4. It looks like we need a separate test on clang's > version. I looked at their version history and sanitizers seem > to have come in around clang 7, so I propose the attached (where > I worked a bit harder on the comment, too). Looks good to me. Thank you for revising! ------ Regards, Alexander Korotkov