Re: shadow variables - pg15 edition - Mailing list pgsql-hackers

From Andres Freund
Subject Re: shadow variables - pg15 edition
Date
Msg-id 20221010162732.5stcy665zsyxkaq6@awork3.anarazel.de
Whole thread Raw
In response to Re: shadow variables - pg15 edition  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: shadow variables - pg15 edition  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
Hi,

On 2022-10-10 12:06:22 -0400, Tom Lane wrote:
> Scraping the configure logs also shows that only half of the buildfarm
> (exactly 50 out of 100 reporting animals) knows -Wshadow=compatible-local,
> which suggests that we might see more of these if they all did.

I think it's not just newness - only gcc has compatible-local, even very new
clang doesn't.


This was fixed ~6 years ago in perl:

commit f2b9631d5d19d2b71c1776e1193173d13f3620bf
Author: David Mitchell <davem@iabyn.com>
Date:   2016-05-23 14:43:56 +0100

    CX_POP_SAVEARRAY(): use more distinctive var name

    Under -Wshadow, CX_POP_SAVEARRAY's local var 'av' can generate this
    warning:

        warning: declaration shadows a local variable [-Wshadow]

    So rename it to cx_pop_savearay_av to reduce the risk of a clash.

    (See http://nntp.perl.org/group/perl.perl5.porters/236444)


> Not sure if this is problematic enough to justify removing the switch.
> A plausible alternative is to have a few animals with known-clean Perl
> installations add the switch manually (and use -Werror), so that we find
> out about violations without having warnings in the face of developers
> who can't fix them.  I'm willing to wait to see if anyone complains of
> such warnings, though.

Given the age of affected perl instances I suspect there'll not be a lot of
developers affected, and the number of warnings is reasonably small too. It'd
likely hurt more developers to not see the warnings locally, given that such
shadowing often causes bugs.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: shadow variables - pg15 edition
Next
From: Alvaro Herrera
Date:
Subject: Re: src/test/perl/PostgreSQL/Test/*.pm not installed