Re: Detecting pointer misalignment (was Re: pgsql: Implementation of subscripting for jsonb)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Alexander Korotkov <akorotkov(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Detecting pointer misalignment (was Re: pgsql: Implementation of subscripting for jsonb)
Date: 2021-02-08 01:20:00
Message-ID: 477102.1612747200@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2021-02-08 09:03:46 pgsql: Fix permission checks on constraint violation errors on partitio
Previous Message Tom Lane 2021-02-08 00:47:37 Detecting pointer misalignment (was Re: pgsql: Implementation of subscripting for jsonb)

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2021-02-08 02:21:22 Re: Is Recovery actually paused?
Previous Message Yugo NAGATA 2021-02-08 01:06:46 Re: Is Recovery actually paused?