From 5fe8a920169b51f97d801318499c4840aaec8e7d Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sat, 1 Jun 2013 11:54:39 +0000 Subject: [PATCH] Fix "array subscript is above array bounds" gcc build warnings on trunk using a suitable pointer and cast. git-svn-id: http://svn.osgeo.org/postgis/trunk@11508 b70326c6-7e19-0410-871a-916f4a2858ee --- libpgcommon/gserialized_gist.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libpgcommon/gserialized_gist.h b/libpgcommon/gserialized_gist.h index 4f44f373c..c8e2215b7 100644 --- a/libpgcommon/gserialized_gist.h +++ b/libpgcommon/gserialized_gist.h @@ -64,13 +64,16 @@ void gidx_expand(GIDX *a, float d); char* gidx_to_string(GIDX *a) ; #endif +/* typedef to correct array-bounds checking for casts to GIDX - do not + use this ANYWHERE except in the casts below */ +typedef float _gidx_float_array[sizeof(float) * 2 * 4]; /* Returns number of dimensions for this GIDX */ #define GIDX_NDIMS(gidx) ((VARSIZE((gidx)) - VARHDRSZ) / (2 * sizeof(float))) /* Minimum accessor. */ -#define GIDX_GET_MIN(gidx, dimension) ((gidx)->c[2*(dimension)]) +#define GIDX_GET_MIN(gidx, dimension) (*((_gidx_float_array *)(&(gidx)->c)))[2*(dimension)] /* Maximum accessor. */ -#define GIDX_GET_MAX(gidx, dimension) ((gidx)->c[2*(dimension)+1]) +#define GIDX_GET_MAX(gidx, dimension) (*((_gidx_float_array *)(&(gidx)->c)))[2*(dimension)+1] /* Minimum setter. */ #define GIDX_SET_MIN(gidx, dimension, value) ((gidx)->c[2*(dimension)] = (value)) /* Maximum setter. */ -- 2.50.1