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.96) (envelope-from ) id 1wFmTW-005XRF-2B for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2026 05:19:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFmTU-00H5yl-1a for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2026 05:19:40 +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.96) (envelope-from ) id 1wFmTU-00H5yX-0O for pgsql-hackers@lists.postgresql.org; Thu, 23 Apr 2026 05:19:40 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wFmTR-00000002aj7-46xU for pgsql-hackers@lists.postgresql.org; Thu, 23 Apr 2026 05:19:39 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-43d77f6092eso4250464f8f.2 for ; Wed, 22 Apr 2026 22:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776921575; cv=none; d=google.com; s=arc-20240605; b=JFk3HWejEQb7508GSHLn7YewOj5gVMuAFaA2JYjMy8gZtTp4saXbSa5YUdOfhYkZAD T/Mj4zivkyJ/eIQzrA2cXIEBqAe2NNoYuSUBrQYa+gpRNjwiZGXGGmRlVZ/LuGT7CnZp dbEF7Dch5LvzL/Si7RlfUo/XU7FKnJazXVapN5RhFk+Yr4pA/ksGijVPvyI5vrj69H34 q16t/YrCW2s2cb7v4Fwh3q63JyN4rdYtY748BA3WOLJKycB+NA2Tekna4R5njotxlNoR ebFJXyASYtKqd1+Bn3fAmxnAjwRjheyaHD8v+zCmU49OS2NXr/d7x5sYGy0z32bgrdmh usmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=jc0YDJTiOOgSxlXla8DgkmydZiMn03jqU5iD4J8ihek=; fh=9MS35lMZifwd7ouhkyKffsQkeLazWk6pQzkPSRzoRQQ=; b=cSQDW/yacSeCLTv5Bxu2B4iYmuTwKU907kEeFHJ9zrCxS2Nxr2NqzX6tx3F1O+WR6f h21YYENaHzDbo9MT/QJQr//1dYP4+UQmW6HwGlWzvYWXGJb86FO63VFlBmTPoc1Akf1v +aqd6nkPkTkm5UrqKLCPm8VJ8hR8xliY8z0awVEcfPzAz/CV6snlCT1Pkv/m/oxGsHbD CHbABCwWL0IiO//xrRau7UK12kzXzE7bwa6pJlqmWIMDpcjx1Yavr1TIlaN2Il/mKdWl h/yfv+afaub0yttEIhQ5+wy0AFGPiB//B2y6FLx+asrITly0yXO5QLcD2HGfPzqCVuX/ A+gQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776921575; x=1777526375; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jc0YDJTiOOgSxlXla8DgkmydZiMn03jqU5iD4J8ihek=; b=lVQ5LTWFRK2ENiW/gMh1BngEEUnRMe7V465FMqvtRIaeOAYl3DWmEKb/poOWiNbAKB QzPdZKsNZ6yvoh6Hh5Ifidzalc+4FUZxhwuh1MKdlFmsiuAMWKbAf1dIWyTwluSDWrOF mna/NnV3h2PhvXEX8tSS+pbXGDd1KLXK322ep9HLalUC+EDgW14eYV3PnT0DjDiA/P0Y 0QMpYJfxCECPrqOlESv5cJ1KTbDsVfhbU5A6jSK88KOIgPv3qCHdUo6BnNQHwp+AGeTp TALPulbnYdDEa2jOI0LCagoyTfQvIPmwRrrp0zq43MDjivhYkk/HVB8KpiLB+EXRiNa1 LAOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776921575; x=1777526375; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jc0YDJTiOOgSxlXla8DgkmydZiMn03jqU5iD4J8ihek=; b=NHDBdlyx13XsqGcF+Ab4xDobqjZFrYz32cwagK3SER+d6/vtFZ8HGkZA7cs+cGP1g3 TACEDIHolsLndMWuzXsNoNP5mkqEeCKr/jltie2dRRlyxhJEJt+69Qoml2shVkaPjMnM /g4iY7GDLOYdHpjOmwInVUGLhEk4RVA68g65aPn3BYHpSu9Vh6SIIMDiityBtokBYT35 P2Xg+JzR8LJoylBm1jiaxpa0UEX3wIfcI4+DDVULgBpfjXZ5LTxbkGOXk1bVPx/3VPY6 loHcYHy6ivWquWWqZtBFOdM1eVWdZjocNSvU12UBUpSTOPDRbofo8cPdrlDvRPUYY7Hm IFIg== X-Forwarded-Encrypted: i=1; AFNElJ8luYScahihsryevHIL8DoMwGGBO1fdwx2qsJutO3m/BexGpa1bTP2VcTdds4/UVT1OyInfVkR7YogLP5hr@lists.postgresql.org X-Gm-Message-State: AOJu0Yw+sY0Eqe/0ZWB/1IGoZmmExTK9gzXBtqNlM4s1j6xe9hAE4igg tJU+hve9IUHlL+OwF5pbr3DW6udv1g/bXUKohLN1R4A0jRiBtzV0lLGAlHLgHdZ5PKXk2E4MIzl 49Fgp6JuV2klTT4jqGcCmHOE4OQUwyQs= X-Gm-Gg: AeBDieslfkjQ0Dfovqmo8S/LSB+UHzDAb6f6IyCcyE6dKxmcsH0Nx5JBqF5sFNF79ow 8EBL7oszpUvwul/jJOUQhDaJ/niUW0dsra9QpeQHYRIhWxaw17RTUwPfb0gFZKGFyydRiRnFKYv w3VgHSjMY00aZaVDKU9TKwcbkO3OntAFGFAM+hwh+vVRwltwVLBpDyR6m8WDAUuWsCPce+I5Ar0 VnkiXyYSsmf+Xj4ws/3LEEYd38Dvz4479FfDGVxmh9ybhqpN8XTYRNoYwlj76Bu2KWyXsCD0l+F dLRx1RP9jQiwOGxb7i+r9NrkbPXIscv4LM2ZBAZK4i0xAm1OaGRBD+FgvOpctE0jQOmVKJZ7oMK gtFWMaFs= X-Received: by 2002:a05:6000:2909:b0:43d:7403:4b65 with SMTP id ffacd0b85a97d-43fe3dbee20mr38496139f8f.6.1776921574837; Wed, 22 Apr 2026 22:19:34 -0700 (PDT) MIME-Version: 1.0 References: <8B830174-7794-411F-B936-37DDB509EC5D@gmail.com> In-Reply-To: <8B830174-7794-411F-B936-37DDB509EC5D@gmail.com> From: David Rowley Date: Thu, 23 Apr 2026 17:19:22 +1200 X-Gm-Features: AQROBzCeDfwuKnO_JWu3Fj1LbR_pQcVVAifsw9V0Re7I_oG26e5x5mnpqFz0cDk Message-ID: Subject: Re: Cleanup shadows variable warnings, round 1 To: Chao Li Cc: =?UTF-8?Q?=C3=81lvaro_Herrera?= , Postgres hackers , Peter Eisentraut , Peter Smith Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 22 Apr 2026 at 17:14, Chao Li wrote: > The attached new v1 patch fixes the v19-only shadow warnings. There are not many. I strictly limited it to warnings newly introduced in v19, without touching any pre-existing ones, even where an old occurrence is very close to a new one. Thank you. I pushed those after some adjustments. While doing that, I did think more on if we should do more of this for v20. I keep thinking back to the times when I've had to write 6 different versions of a patch to back patch to 6 different branches. It's rarely that bad, but it sure does make you swear when the 6th "git am" fails, especially when you find out that it was for a very trivial thing, such as a spelling mistake fix. You really have to fight off the temptation of complacency after the first 3 or so failed git ams. A worse category of problems that this particular set of patches could cause is no conflict when we want one. I personally always write bug fixes for master and back-patch them, but if anyone were to work forward to newer versions, then imagine someone adding some code to a function that does something with a local variable that's shadowed globally. If they forward patch that to a version where the local variable has been renamed, everything compiles and might appear to work, but it's now the global that's being changed when the new code was meant to change the local. Maybe no committers work that way, but if they do, it's a real risk. IMO, without any references to recent bugs that have been fixed due to shadowing, then I can't see beyond the fact that this might be more likely to cause bugs than to prevent them. As I recall, we were about borderline on doing -Wshadow=compatible-local. At least for non-compatible variables, I'd expect you'd get a warning or error during compilation. For the record, I got motivated for Justin's work on the compatible-local due to af7d270dd. I removed a shadowed variable which was incorrect. In my view, Justin Pryzby's proposal to do something about this was well timed. I'm not seeing the same thing happen here. Maybe I missed it? David