Re: compiler warnings on the buildfarm - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: compiler warnings on the buildfarm
Date
Msg-id 4696ADEA.1040804@enterprisedb.com
Whole thread Raw
In response to Re: compiler warnings on the buildfarm  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Heikki Linnakangas <heikki@enterprisedb.com> 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?

Yes, I don't get it with -O1 or -O0.

$ gcc --version
gcc (GCC) 4.1.2 20061028 (prerelease) (Debian 4.1.1-19)

Hmm. Prerelease? This version came from debian/testing.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: compiler warnings on the buildfarm
Next
From: Tom Lane
Date:
Subject: Re: compiler warnings on the buildfarm