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

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: lots of unused variable warnings in assert-free builds
Date: 2012-01-15 14:02:16
Message-ID: CA+U5nMJvYVHZwQ7mshPktXjKhVreGHRosqBZ1RrQoZaw4+Yz2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 15, 2012 at 1:14 PM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
>
> On 01/15/2012 01:37 AM, Tom Lane wrote:
>>
>> Peter Eisentraut<peter_e(at)gmx(dot)net>  writes:
>>>
>>> I see that in some places our code already uses #ifdef
>>> USE_ASSERT_CHECKING, presumably to hide similar issues.  But in most
>>> cases using this would significantly butcher the code.  I found that
>>> adding __attribute__((unused)) is cleaner.  Attached is a patch that
>>> cleans up all the warnings I encountered.
>>
>> Surely this will fail entirely on most non-gcc compilers?  Not to
>> mention that next month's gcc may complain "hey, you used this 'unused'
>> variable".  I think #ifdef USE_ASSERT_CHECKING is really the only way
>> if you care about quieting these warnings.  (Personally, I don't.)
>>
>>
>
>
>
> It would possibly have some documentary value too. Just looking very quickly
> at Peter's patch, I don't really understand his assertion that this would
> significantly butcher the code. The worst effect would be that in a few
> cases we'd have to break up multiple declarations where one of the variables
> was in this class. That doesn't seem like a tragedy.
>
> I like software that compiles in the normal use with few or no warnings. I
> should have thought that would appeal to most packagers, too.

Sounds good, but let's not do it yet because we have a few patches to
commit first.

It would be good to minimise bit rot during the CF.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2012-01-15 14:34:12 Re: pgstat documentation tables
Previous Message Andrew Dunstan 2012-01-15 13:14:52 Re: lots of unused variable warnings in assert-free builds