From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6466 invoked by alias); 1 Dec 2011 04:15:55 -0000 Received: (qmail 4159 invoked by uid 22791); 1 Dec 2011 04:15:49 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Dec 2011 04:15:33 +0000 Received: by iaqq3 with SMTP id q3so2253521iaq.0 for ; Wed, 30 Nov 2011 20:15:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.163.97 with SMTP id yh1mr6193235igb.37.1322712933070; Wed, 30 Nov 2011 20:15:33 -0800 (PST) Received: by 10.50.186.228 with HTTP; Wed, 30 Nov 2011 20:15:33 -0800 (PST) In-Reply-To: References: <201111231640.pANGefc4031803@d06av02.portsmouth.uk.ibm.com> <201111231820.40486.pedro@codesourcery.com> <201111232023.pANKNcLf022983@glazunov.sibelius.xs4all.nl> <20111124220057.GU13809@adacore.com> <20111125142615.GV13809@adacore.com> Date: Thu, 01 Dec 2011 04:15:00 -0000 Message-ID: Subject: Re: [PATCH 18/348] Fix -Wsahdow warnings From: Andrey Smirnov To: Tom Tromey Cc: Joel Brobecker , gdb-patches Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-12/txt/msg00000.txt.bz2 On Wed, Nov 30, 2011 at 9:59 PM, Tom Tromey wrote: >>>>>> "Andrey" =3D=3D Andrey Smirnov writes: > > Andrey> I hope that kinds of shadowing would still be detectable even wit= h this > Andrey> patch applied. > > Why is that? Because when somebody decides to modify such a code and rename/remove local variables, compiler will not warn them about any leftover pieces of code referencing now renamed/non-existent variable. And on some occasions that would lead to introduction of weird, not so easy to reproduce bugs. Although generally I think functionality introduced by that patch should have been optional. In my opinion C gives one enough of an arsenal to shoot their own foot, so while Mark is adamant that scalar variables will never be the cause of a bug, I remain unconvinced and still think that even such unlikely cause is still a cause. But then again it is just my opinion, I do not have real world examples, and it looks like my synthetic ones are not very persuasive. > Andrey> It would pretty much solve that problem, yes, but still it would > Andrey> divide patch submitters into two groups those who have newest gcc= and > Andrey> -Wshadow enabled by default, and those who don't. And the people > Andrey> without -Wshadow enabled compilers would be, on occasion, breakin= g the > Andrey> build because they have no means to check for -Wshadow caused err= ors. > Andrey> I hope I missing something and it is not the case, but that how t= he > Andrey> things seems to me now. > > Yes, I think it would result in some periodic breakage until the newer > GCC is widely distributed. =A0I'm willing to put up with that. =A0We alre= ady > put up with it, in a way, due to other GCC differences... see the > uninitialized variable patches or FORTIFY_SOURCE patches that go in from > time to time. > But those are pretty much the results we would get with enabling -Wshadow on all versions of gcc but on a per-platform basis. BTW I'm just playing Devil's advocate here, IMHO, your solution is still better than no -Wshadow at all. > If the configury part is set up properly, then this warning will simply > auto-enable for people when they upgrade GCC. =A0So, it isn't like we'll > just forget about it; more like at some point we'll all be joining in :) I wish this world would have less small, city-local companies, doing embedded development whose version of GCC is fixed in stone because the whole building system is so obscure to anyone that no one dares to introduce any changes to it, and usually no one even cares. I used to work in such a place, so I know that some people will be left behind. :-) Andrey Smirnov