Re: new clang warnings about unused global variables

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Andrei Lepikhov <lepihov(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andreas Karlsson <andreas(at)proxel(dot)se>
Subject: Re: new clang warnings about unused global variables
Date: 2026-11-25 16:29:09
Message-ID: 04f6ed14-962c-4d01-8e19-3f92c0dbbcb2@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 24.11.26 14:04, Andrei Lepikhov wrote:
> Building current master on macOS with a recent clang, I still get two of these
> warnings, both in psql:
>
> input.c:36:12: warning: variable 'history_lines_added' set but not used
> [-Wunused-but-set-global]
> tab-complete.in.c:225:13: warning: variable 'completion_last_char' set but not
> used [-Wunused-but-set-global]
>
> They only appear when psql is linked against a line-editing library that lacks
> some optional functions, such as libedit, which ships with macOS. That is
> probably why they didn't show up in your build.
>
> See the sketch solution in the attached patch.

Maybe for cases like this it would be easier to stick a
pg_attribute_unused() on the variable declarations. Otherwise, it might
get too annoying to maintain all these #ifdef groups consistently.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2026-11-25 16:41:41 Re: repack: clarify final phase of concurrent mode in file header comment
Previous Message Fabrice Chapuis 2026-11-25 16:27:33 Re: unidirectional logical replication logging issue