Re: Cleanup shadows variable warnings, round 1

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Cleanup shadows variable warnings, round 1
Date: 2025-11-29 15:29:47
Message-ID: c981068f-008a-4951-992a-4d2159b9d656@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28.11.25 09:16, Chao Li wrote:
> Hi Hackers,
>
> While reviewing [1], it makes me recall an experience where I had a
> patch ready locally, but CommitFest CI failed with a shadows-variable
> warning. Now I understand that -Wall doesn't by default enable -Wshadows
> with some compilers like clang.
>
> I did a clean build with manually enabling -Wshadow and
> surprisingly found there are a lot of such warnings in the current code
> base, roughly ~200 occurrences.
>
> As there are too many, I plan to fix them all in 3-4 rounds. For round 1
> patch, I'd see any objection, then decide if to proceed more rounds.

See
<https://www.postgresql.org/message-id/flat/20220817145434.GC26426%40telsasoft.com>
for a previous long thread on this, which led to the addition of the
-Wshadow=compatible-local flag.

I think this is a slightly unsatisfactory state, because that is a
gcc-specific option, and maybe you are using clang or something else.
So maybe some further cleanup is useful, but please check the previous
discussions.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2025-11-29 15:36:41 Re: Migrate to autoconf 2.72?
Previous Message Andres Freund 2025-11-29 14:53:38 Re: pgsql: Inline pg_ascii_tolower() and pg_ascii_toupper().