Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgXrz-0002D0-8u for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Feb 2017 14:26:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cgXry-0004QE-S1 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Feb 2017 14:26:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cgXrx-0004Ot-2H for pgsql-hackers@postgresql.org; Wed, 22 Feb 2017 14:26:13 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cgXrt-0003go-50 for pgsql-hackers@postgresql.org; Wed, 22 Feb 2017 14:26:12 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id D4F9C22670; Wed, 22 Feb 2017 09:26:07 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Wed, 22 Feb 2017 09:26:07 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=LJzXgnr8KHZbz4 DZ2Kv90Z5xbrw=; b=elQIy1mSIfMSzobpspKEDpdHYzBlh+Ui3fmtTUbjMt8qXN U0kibutWdXsUy6A/cWcR2jvtwGk4P/C3JWR6Zqk3SfbAOfTsSf1kdZPDQTmHOTkZ iDDwXTRYF3EWNVjc8EL1UREKJxxzzDpl0RscBwYaGkwHF12xq1NW4mhw5YsBI= X-ME-Sender: X-Sasl-enc: xyCHC1ygaWk2T1LbX5k2Rcv9RDi/R1/qu0c+wUgh+XJP 1487773567 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 9D07A7E31E; Wed, 22 Feb 2017 09:26:07 -0500 (EST) Subject: Re: "may be unused" warnings for gcc To: Andres Freund References: <20170220144118.qqq3zp2lnuq52e4c@alap3.anarazel.de> <20170222031722.kof3yzn5jfnf6jy4@alap3.anarazel.de> Cc: pgsql-hackers@postgresql.org From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <15fb2350-b8b8-e188-278f-0b34fdee5210@2ndquadrant.com> Date: Wed, 22 Feb 2017 09:26:10 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170222031722.kof3yzn5jfnf6jy4@alap3.anarazel.de> Content-Type: multipart/mixed; boundary="------------D1DCDDEEF37E8935610864A8" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------D1DCDDEEF37E8935610864A8 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 2/21/17 22:17, Andres Freund wrote: > I've not run comparisons this year, but late last year I was seeing > 5% > < 10% benefits - that seems plenty enough to care. You mean the 5-minute benchmarks on my laptop are not representative? ;-) Here is a patch that I had lying around that clears the compiler warnings under -O3 for me. It seems that they are a subset of what you are seeing. Plausibly, as compilers are doing more analysis in larger scopes, we can expect to see more of these. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------D1DCDDEEF37E8935610864A8 Content-Type: text/x-patch; name="0001-Silence-compiler-warnings-from-gcc-O3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Silence-compiler-warnings-from-gcc-O3.patch" From 2a73d3ac095435ecbe3aefff7bcecc292675e167 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 22 Feb 2017 09:23:40 -0500 Subject: [PATCH] Silence compiler warnings from gcc -O3 --- src/backend/commands/dbcommands.c | 13 +++++++------ src/backend/utils/adt/varlena.c | 6 ++++++ src/backend/utils/misc/guc.c | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 1ebacbc24f..2a23f634c5 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -27,6 +27,7 @@ #include "access/genam.h" #include "access/heapam.h" #include "access/htup_details.h" +#include "access/multixact.h" #include "access/xact.h" #include "access/xloginsert.h" #include "access/xlogutils.h" @@ -103,14 +104,14 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt) Relation rel; Oid src_dboid; Oid src_owner; - int src_encoding; - char *src_collate; - char *src_ctype; + int src_encoding = -1; + char *src_collate = NULL; + char *src_ctype = NULL; bool src_istemplate; bool src_allowconn; - Oid src_lastsysoid; - TransactionId src_frozenxid; - MultiXactId src_minmxid; + Oid src_lastsysoid = InvalidOid; + TransactionId src_frozenxid = InvalidTransactionId; + MultiXactId src_minmxid = InvalidMultiXactId; Oid src_deftablespace; volatile Oid dst_deftablespace; Relation pg_database_rel; diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 28b5745ba8..7da7535b3b 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -1129,6 +1129,8 @@ text_position_setup(text *t1, text *t2, TextPositionState *state) state->use_wchar = false; state->str1 = VARDATA_ANY(t1); state->str2 = VARDATA_ANY(t2); + state->wstr1 = 0; + state->wstr2 = 0; state->len1 = len1; state->len2 = len2; } @@ -1144,6 +1146,8 @@ text_position_setup(text *t1, text *t2, TextPositionState *state) len2 = pg_mb2wchar_with_len(VARDATA_ANY(t2), p2, len2); state->use_wchar = true; + state->str1 = 0; + state->str2 = 0; state->wstr1 = p1; state->wstr2 = p2; state->len1 = len1; @@ -1227,6 +1231,8 @@ text_position_setup(text *t1, text *t2, TextPositionState *state) state->skiptable[wstr2[i] & skiptablemask] = last - i; } } + else + state->skiptablemask = 255; } static int diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 24771389c8..107e1f2957 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -9275,7 +9275,7 @@ RestoreGUCState(void *gucstate) char *varname, *varvalue, *varsourcefile; - int varsourceline; + int varsourceline = -1; GucSource varsource; GucContext varscontext; char *srcptr = (char *) gucstate; -- 2.11.1 --------------D1DCDDEEF37E8935610864A8 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------D1DCDDEEF37E8935610864A8--