]> granicus.if.org Git - postgis/commitdiff
Fix "array subscript is above array bounds" gcc build warnings on trunk using a suita...
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sat, 1 Jun 2013 11:54:39 +0000 (11:54 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sat, 1 Jun 2013 11:54:39 +0000 (11:54 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@11508 b70326c6-7e19-0410-871a-916f4a2858ee

libpgcommon/gserialized_gist.h

index 4f44f373c997b39c5adba390b8b3c78ea45b2df9..c8e2215b7cf6cd4b152f76833f223777ffd3f09f 100644 (file)
@@ -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. */