Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id ACF769FBB3A for ; Thu, 12 Jul 2007 19:51:50 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 45973-07 for ; Thu, 12 Jul 2007 19:51:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by postgresql.org (Postfix) with ESMTP id 968EE9FB61E for ; Thu, 12 Jul 2007 19:51:44 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id f5so21599nfh for ; Thu, 12 Jul 2007 15:51:39 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:sender; b=TBRFl4kT0Q6TTlES6no/BE2i4X53dv6VfOsEL9eoIqn7kFzHTMonlKGNRzYzpa6LVG0zexXdEs+NVJhOSoTd5yekhX3bk8RW5On3GsPRB+zURueYxS+M0C0Vl0twhivwbefTywHOgLXzn5Qd1xOFK8U31MWh6QgwQ7WpjwUmbFw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:sender; b=A3BylbBB+RaJDXaQNft7Xii5wxT9DL22PAHfnuuBtEjjkwml5FkPX7hI37n9evlL1bDWng4IdUAybn6+9KnNA605lrgRDbnt88P53bd1QCN1nnooHkZEn4KRQBU3pHLJ7BzpcWlkToLsyggp/kCEecTI+smyY4EG/qKjqBQaRuE= Received: by 10.82.182.1 with SMTP id e1mr1396753buf.1184280699308; Thu, 12 Jul 2007 15:51:39 -0700 (PDT) Received: from ?192.168.1.33? ( [86.27.69.36]) by mx.google.com with ESMTP id 6sm8609568nfv.2007.07.12.15.51.36 (version=SSLv3 cipher=RC4-MD5); Thu, 12 Jul 2007 15:51:37 -0700 (PDT) Message-ID: <4696B045.8080405@enterprisedb.com> Date: Thu, 12 Jul 2007 23:50:45 +0100 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.10 (X11/20070329) MIME-Version: 1.0 To: Tom Lane CC: Alvaro Herrera , Stefan Kaltenbrunner , PostgreSQL-development Subject: Re: compiler warnings on the buildfarm References: <46962BBD.5000108@kaltenbrunner.cc> <17428.1184249229@sss.pgh.pa.us> <469653BA.2040004@kaltenbrunner.cc> <20070712211918.GD22973@alvh.no-ip.org> <46969C98.60207@enterprisedb.com> <20070712213806.GE22973@alvh.no-ip.org> <4696A5F1.3010103@enterprisedb.com> <12639.1184279380@sss.pgh.pa.us> In-Reply-To: <12639.1184279380@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------050102080101090509030802" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/358 X-Sequence-Number: 105273 This is a multi-part message in MIME format. --------------050102080101090509030802 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Tom Lane wrote: > Heikki Linnakangas writes: >> Hmm. It looks like I get that warning on my laptop as well. I tracked it >> down to these two places: > >> Line 209: >>> while (ptr - GETARR(trg) < ARRNELEM(trg)) >>> { >>> text *item = (text *) palloc(VARHDRSZ + 3); >>> >>> SET_VARSIZE(item, VARHDRSZ + 3); >>> CPTRGM(VARDATA(item), ptr); >>>>> d[ptr - GETARR(trg)] = PointerGetDatum(item); >>> ptr++; >>> } > > I'll betcha the compiler is trying to optimize the repeated calculations > of "ptr - GETARR(trg)" into a separate variable that it increments along > with ptr. Maybe it is getting it wrong, or maybe the assembler is just > confused. Does the warning go away if you dial down the -O level? FWIW, this patch makes the warnings go away, and makes the code a little bit more readable as well. It would be nice to understand why exactly it's complaining, though. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com --------------050102080101090509030802 Content-Type: text/x-diff; name="trgm-silence-warning.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="trgm-silence-warning.patch" Index: trgm_op.c =================================================================== RCS file: /home/hlinnaka/pgcvsrepository/pgsql/contrib/pg_trgm/trgm_op.c,v retrieving revision 1.8 diff -c -r1.8 trgm_op.c *** trgm_op.c 28 Feb 2007 22:44:38 -0000 1.8 --- trgm_op.c 12 Jul 2007 22:28:43 -0000 *************** *** 194,212 **** Datum *d; ArrayType *a; trgm *ptr; trg = generate_trgm(VARDATA(in), VARSIZE(in) - VARHDRSZ); d = (Datum *) palloc(sizeof(Datum) * (1 + ARRNELEM(trg))); ! ptr = GETARR(trg); ! while (ptr - GETARR(trg) < ARRNELEM(trg)) { text *item = (text *) palloc(VARHDRSZ + 3); SET_VARSIZE(item, VARHDRSZ + 3); CPTRGM(VARDATA(item), ptr); ! d[ptr - GETARR(trg)] = PointerGetDatum(item); ! ptr++; } a = construct_array( --- 194,211 ---- Datum *d; ArrayType *a; trgm *ptr; + int i; trg = generate_trgm(VARDATA(in), VARSIZE(in) - VARHDRSZ); d = (Datum *) palloc(sizeof(Datum) * (1 + ARRNELEM(trg))); ! for (i = 0, ptr = GETARR(trg); i < ARRNELEM(trg); i++, ptr++) { text *item = (text *) palloc(VARHDRSZ + 3); SET_VARSIZE(item, VARHDRSZ + 3); CPTRGM(VARDATA(item), ptr); ! d[i] = PointerGetDatum(item); } a = construct_array( *************** *** 218,229 **** 'i' ); ! ptr = GETARR(trg); ! while (ptr - GETARR(trg) < ARRNELEM(trg)) ! { ! pfree(DatumGetPointer(d[ptr - GETARR(trg)])); ! ptr++; ! } pfree(d); pfree(trg); --- 217,224 ---- 'i' ); ! for (i = 0; i < ARRNELEM(trg); i++) ! pfree(DatumGetPointer(d[i])); pfree(d); pfree(trg); --------------050102080101090509030802--