From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22562 invoked by alias); 25 Nov 2011 15:41:17 -0000 Received: (qmail 22553 invoked by uid 22791); 25 Nov 2011 15:41:16 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout21.012.net.il (HELO mtaout21.012.net.il) (80.179.55.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Nov 2011 15:41:02 +0000 Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0LV80050038WBA00@a-mtaout21.012.net.il> for gdb-patches@sourceware.org; Fri, 25 Nov 2011 17:41:00 +0200 (IST) Received: from HOME-C4E4A596F7 ([84.228.50.247]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LV8004Q73KBY0B0@a-mtaout21.012.net.il>; Fri, 25 Nov 2011 17:41:00 +0200 (IST) Date: Fri, 25 Nov 2011 15:41:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH 18/348] Fix -Wsahdow warnings In-reply-to: <201111251511.pAPFBBkP007292@glazunov.sibelius.xs4all.nl> To: Mark Kettenis Cc: brobecker@adacore.com, andrew.smirnov@gmail.com, gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83ehww8b1t.fsf@gnu.org> References: <201111231640.pANGefc4031803@d06av02.portsmouth.uk.ibm.com> <201111231820.40486.pedro@codesourcery.com> <201111232023.pANKNcLf022983@glazunov.sibelius.xs4all.nl> <20111124220057.GU13809@adacore.com> <83hb1s8l5c.fsf@gnu.org> <201111251511.pAPFBBkP007292@glazunov.sibelius.xs4all.nl> 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-11/txt/msg00698.txt.bz2 > Date: Fri, 25 Nov 2011 16:11:11 +0100 (CET) > From: Mark Kettenis > CC: brobecker@adacore.com, andrew.smirnov@gmail.com, > gdb-patches@sourceware.org > > > If it surprised you, it means -Wsahdow did its job well. > > No it didn't. It does a poor job, by flagging cases that can never > ever cause problems. A local variable "shadowing" a global function > name will never be a problem, because something like: > > void foo(void); > > void > bar(void) > { > int foo; > > foo(); > } > > simply won't compile, even if you don't use -Werror. But the patches suggested by Andrey didn't find any instances of the above. So I submit that this danger is purely theoretical at this point, or at least sufficiently rare in GDB to render this consideration not important in practice for us. > > IOW, it's easy to avoid well-known names like `printf' or `strchr'. > > It's the not-so-well-known names that give you hell and high water. > > Exactly. And since we enable -Werror by default, -Wshadow will break > GDB builds for no good reason. Clashing with library symbols _is_ a good reason to prevent GDB from building. > And remove some perfectly usable and meaningful variable names. They can be easily replaced by no less meaningful and usable ones. > > > Add the fact that includes and compiler vary from system to system, > > > and we're not sure that once clean on one machine, it'll be clean > > > everywhere else. > > > > But this is true of any other non-trivial piece of our code. E.g., if > > you declare a variable `long' expecting it to be a 64-bit type, this > > will break on MS-Windows, and you will never no until you actually try > > such a compilation. > > Well, that would be a wrong assumption on any sane 32-bit platform as > well, so that issue could be caught on most platforms that GDB runs on. What about the assumption that a long is as wide as a pointer? Don't dismiss a principle just because one of its examples can be easily refuted. > > In general, we have no bullet-proof way of making sure our code works > > on all supported platforms, except by actually compiling it on those > > platforms. That's why platforms which lose their area maintainers > > bit-rot quite quickly. This compiler switch doesn't change this > > situation in any way. > > I disagree. -Wshadow is a game changer because actually compiling on > *all* plaforms is the only way to make sure that I don't actually > break anything. That's extremely bad! The same is true of any code you add or change, with the possible exception of very trivial changes. > Most people that contribute to GDB are fairly competent programmers. Being competent doesn't mean being clairvoyant. How can we trust ourselves to know by heart every single symbol in the standard libraries?