Re: new clang warnings about unused global variables

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: new clang warnings about unused global variables
Date: 2026-09-03 13:30:54
Message-ID: 65c29091-1ca0-41e6-ba58-c5fc1cbfa01a@proxel.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 9/3/26 15:01, Peter Eisentraut wrote:
> On 28.08.26 23:33, Peter Eisentraut wrote:
>> The new clang 23 has a new warning apparently enabled by default (at
>> least by default in a PostgreSQL build) about set-but-unused static
>> global variables: -Wunused-but-set-global.  This triggers a few
>> warnings in PostgreSQL code.  See attached patches.  The first four of
>> these are genuine hits; these variables were never read from or the
>> last reading use was removed some time ago.  The last one in pg_ctl is
>> about options that can be set from the command line on any platform
>> but are only used on Windows.  This seems kind of weird behavior;
>> maybe in the future we should make those options error out on non-
>> Windows, and then the variables wouldn't be uselessly set.

The rest look good but ot sure I like the last patch. Wouldn't we want
to get an error on unused on Windows builds? The patch would hide if we
stop using one of them on Windows.

> I sense that nobody is going to have issues with this.  Any objections
> to backpatching this?  I suspect that over time many more people are
> going to run into this, so keeping the backbranches warning-free seems
> sensible.

Yeah, as the changes are simple and only touch unused static globals I
do not see any risk with backporting.

--
Andreas Karlsson
Percona

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-09-03 13:31:45 Re: SSI: ON CONFLICT DO SELECT takes no predicate lock on the returned row
Previous Message cca5507 2026-09-03 13:17:18 Re: [PATCH] Allow bare library names for non-superuser LOAD