Tomas Vondra <tomas.von...@2ndquadrant.com> writes: > On Tue, Jun 25, 2019 at 11:52:28PM -0400, Tom Lane wrote: >> You can *not* cast something to an aligned pointer type if it's not >> actually certain to be aligned suitably for that type.
> OK. So the solution is to ditch the casts altogether, and then do plain > pointer arithmetics like this: > #define ITEM_INDEXES(item) (item) > #define ITEM_NULLS(item,ndims) (ITEM_INDEXES(item) + (ndims)) > #define ITEM_FREQUENCY(item,ndims) (ITEM_NULLS(item, ndims) + (ndims)) > #define ITEM_BASE_FREQUENCY(item,ndims) (ITEM_FREQUENCY(item, ndims) + > sizeof(double)) > Or is that still relying on alignment, somehow? No, constructs like a char* pointer plus n times sizeof(something) should be safe. regards, tom lane