From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Remove shadowed declaration warnings |
Date: | 2024-09-12 02:02:59 |
Message-ID: | 3935878.1726106579@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> On Thu, 12 Sept 2024 at 12:33, Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>> I normally build the code with warnings enabled (specifically,
>> -Wshadow) which exposes many "shadowed" declarations.
> 0fe954c28 did add -Wshadow=compatible-local to the standard set of
> complication flags. I felt it was diminishing returns after that, but
> -Wshadow=local would be the next step before going full -Wshadow.
I think that insisting that local declarations not shadow globals
is an anti-pattern, and I'll vote against any proposal to make
that a standard warning. Impoverished as C is, it does have block
structure; why would we want to throw that away by (in effect)
demanding a single flat namespace for the entire program?
I do grant that sometimes shadowing of locals can cause bugs. I don't
recall right now why we opted for -Wshadow=compatible-local over
-Wshadow=local, but we could certainly take another look at that.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 2024-09-12 02:03:54 | Re: Add memory/disk usage for WindowAgg nodes in EXPLAIN |
Previous Message | David Rowley | 2024-09-12 01:43:42 | Re: Remove useless GROUP BY columns considering unique index |