Re: lots of unused variable warnings in assert-free builds

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: lots of unused variable warnings in assert-free builds
Date: 2012-01-24 17:57:36
Message-ID: 9063.1327427856@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Tue, Jan 24, 2012 at 12:12 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Ouch. Is it really true that __attribute__((unused)) disables detection
>> of use of uninitialized variables?

> Oh, I think maybe I am confused. The downsides of disabling *unused*
> variable detection are obviously much less than the downsides of
> disabling *uninitialized* variable declaration... although neither is
> ideal.

OK. MHO is that __attribute__((unused)) is probably less annoying than
#ifdef overall. Also, it occurs to me that an intermediate macro
"PG_USED_FOR_ASSERTS_ONLY" would be a good idea, first because it
documents *why* you want to mark the variable as possibly unused,
and second because changing the macro definition would provide an easy way
to check for totally-unused variables, in case we wanted to periodically
make such checks.

This is all modulo the question of what pgindent will do with it,
which I would still like to see tested before we commit to a method.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-01-24 18:03:50 Re: lots of unused variable warnings in assert-free builds
Previous Message Robert Haas 2012-01-24 17:55:56 Re: GUC_REPORT for protocol tunables was: Re: Optimize binary serialization format of arrays with fixed size elements