Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YOpfr-0001lM-7C for pgsql-committers@arkaria.postgresql.org; Fri, 20 Feb 2015 15:39:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YOpfp-0006q1-LA for pgsql-committers@arkaria.postgresql.org; Fri, 20 Feb 2015 15:39:25 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YOpfo-0006pm-Ke for pgsql-committers@postgresql.org; Fri, 20 Feb 2015 15:39:24 +0000 Received: from mout.kundenserver.de ([212.227.126.187]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YOpfk-0007Jq-Jr for pgsql-committers@postgresql.org; Fri, 20 Feb 2015 15:39:22 +0000 Received: from anarazel.de ([93.220.75.248]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0MROX9-1XygEl0OP1-00UeIq; Fri, 20 Feb 2015 16:39:16 +0100 Received: by anarazel.de (Postfix, from userid 1000) id 09C73100BDC; Fri, 20 Feb 2015 16:39:15 +0100 (CET) Date: Fri, 20 Feb 2015 16:39:14 +0100 From: Andres Freund To: Tom Lane Cc: pgsql-committers@postgresql.org, Michael Paquier Subject: Re: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places. Message-ID: <20150220153914.GC12653@awork2.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K0:EgXwLQHsvUSdxMgiaoqgmLPM7a4xczQRy+ejnL7bs5qQW6xUrQN JTyR+JVJtJG/7iLm0x2HszxM/1Aio7Kdx3ybBLx2fiZSS5NO4wOlfisKbaqnElZVZ+FfnzD a4rlKMNZdP8XfWNrmWmE4OqB8MpdItV6ckf10H/qtNPJVDUciffmv51r6WBx6AdYd2vNQ/8 LjQP8ugPeYXjrjZlHLB5A== X-UI-Out-Filterresults: notjunk:1; X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On 2015-02-20 05:12:00 +0000, Tom Lane wrote: > Use FLEXIBLE_ARRAY_MEMBER in a bunch more places. > > Replace some bogus "x[1]" declarations with "x[FLEXIBLE_ARRAY_MEMBER]". > Aside from being more self-documenting, this should help prevent bogus > warnings from static code analyzers and perhaps compiler misoptimizations. > > This patch is just a down payment on eliminating the whole problem, but > it gets rid of a lot of easy-to-fix cases. > > Note that the main problem with doing this is that one must no longer rely > on computing sizeof(the containing struct), since the result would be > compiler-dependent. Instead use offsetof(struct, lastfield). Autoconf > also warns against spelling that offsetof(struct, lastfield[0]). > > Michael Paquier, review and additional fixes by me. This triggers a large number of warnings with my preexisting clang 3.6 settings... In file included from /home/andres/src/postgresql/src/backend/postmaster/pgstat.c:40: /home/andres/src/postgresql/src/include/catalog/pg_proc.h:61:12: warning: 'proargtypes' may not be nested in a struct due to flexible array member [-Wflexible-array-extensions] oidvector proargtypes; /* parameter types (excludes OUT params) */ ^ In file included from /home/andres/src/postgresql/src/backend/executor/execQual.c:40: In file included from /home/andres/src/postgresql/src/include/access/nbtree.h:21: /home/andres/src/postgresql/src/include/catalog/pg_index.h:48:13: warning: 'indkey' may not be nested in a struct due to flexible array member [-Wflexible-array-extensions] int2vector indkey; /* column numbers of indexed cols, or 0 */ and many more. Now, -Wflexible-array-extensions is IIRC not a standard option and I only got it because I use -Weverything and disable the crazy stuff. So maybe it's not worth worrying about. I'll just include -Wno-flexible-array-extensions for now. But I thought it's worth mentioning that at least one person went through the trouble of adding a warning about this ;). I can't really agree in this case because indkey still is the, as far the compiler can see, last element of a struct, even if there's nesting. Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers