Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soZAo-00CBib-Pg for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Sep 2024 02:03:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1soZAm-00COfx-Tl for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Sep 2024 02:03:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soZAm-00COfj-Ji for pgsql-hackers@lists.postgresql.org; Thu, 12 Sep 2024 02:03:04 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soZAi-000jsl-Qa for pgsql-hackers@lists.postgresql.org; Thu, 12 Sep 2024 02:03:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 48C22xOh3935879; Wed, 11 Sep 2024 22:02:59 -0400 From: Tom Lane To: David Rowley cc: Peter Smith , PostgreSQL Hackers Subject: Re: Remove shadowed declaration warnings In-reply-to: References: Comments: In-reply-to David Rowley message dated "Thu, 12 Sep 2024 12:58:19 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3935877.1726106579.1@sss.pgh.pa.us> Date: Wed, 11 Sep 2024 22:02:59 -0400 Message-ID: <3935878.1726106579@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > On Thu, 12 Sept 2024 at 12:33, Peter Smith 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