]> granicus.if.org Git - postgresql/commitdiff
Fix use of offsetof()
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 30 Aug 2016 16:00:00 +0000 (12:00 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 30 Sep 2016 18:00:44 +0000 (14:00 -0400)
Using offsetof() with a run-time computed argument is not allowed in
either C or C++.  Apparently, gcc allows it, but g++ doesn't.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Thomas Munro <thomas.munro@enterprisedb.com>
contrib/bloom/blutils.c

index debf4f46eb7c62737a6813dfc29cba86f901d73f..b68a0d1d0cf09cc5d2612b40e4ca844b133afef8 100644 (file)
@@ -75,7 +75,7 @@ _PG_init(void)
                bl_relopt_tab[i + 1].optname = MemoryContextStrdup(TopMemoryContext,
                                                                                                                   buf);
                bl_relopt_tab[i + 1].opttype = RELOPT_TYPE_INT;
-               bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[i]);
+               bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[0]) + sizeof(int) * i;
        }
 }